Commit f1b8c8dc authored by hkl's avatar hkl

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

parent 2a2816f0
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
<properties> <properties>
<package.environment>dev</package.environment> <package.environment>dev</package.environment>
</properties> </properties>
</profile> </profile>
<!-- 黄康林本地配置--> <!-- 黄康林本地配置-->
......
...@@ -95,10 +95,6 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -95,10 +95,6 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
private IMovementTqiStandardManagerService movementTqiStandardManagerService; private IMovementTqiStandardManagerService movementTqiStandardManagerService;
@Resource @Resource
private AnalysisAlgorithmMapper analysisAlgorithmMapper; private AnalysisAlgorithmMapper analysisAlgorithmMapper;
@Resource
private IRailInspectionEquipmentItemService railInspectionEquipmentItemService;
@Resource
private IRailInspectionEquipmentItemDetailService railInspectionEquipmentItemDetailService;
@Resource @Resource
private AsyncTask asyncTask; private AsyncTask asyncTask;
...@@ -285,40 +281,9 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec ...@@ -285,40 +281,9 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
@ApiOperation(value = "删除动静态几何尺寸数据及相关联的数据", notes = "删除动静态几何尺寸数据及相关联的数据") @ApiOperation(value = "删除动静态几何尺寸数据及相关联的数据", notes = "删除动静态几何尺寸数据及相关联的数据")
@GetMapping(value = "/delete") @GetMapping(value = "/delete")
public Result<String> delete(@ApiParam(name = "动静态几何尺寸数据id", required = true) String id, @ApiParam(name = "动静态几何尺寸数据类型", required = true) String type) { public Result<String> delete(@ApiParam(name = "动静态几何尺寸数据id", required = true) String id, @ApiParam(name = "动静态几何尺寸数据类型", required = true) String type) {
if ("1".equals(type)) {
//人工静态检查相关 this.movementRecordsMasterFace.delete(id, type);
//删除里程详情
movementCourseInfoService.lambdaUpdate().eq(MovementCourseInfo::getMovementMasterId, id).remove();
//删除里程相关
movementCourseService.lambdaUpdate().eq(MovementCourse::getMovementMasterId, id).remove();
} else if ("2".equals(type)) {
// 删除里程
railInspectionEquipmentItemService.lambdaUpdate().eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, id).remove();
// 删除里程明细
railInspectionEquipmentItemDetailService.lambdaUpdate().eq(RailInspectionEquipmentItemDetail::getRailInspectionEquipmentId, id).remove();
} else if ("4".equals(type)) {
//删除添乘仪详情
movementAdditiveInfoService.lambdaUpdate().eq(MovementAdditiveInfo::getMovementMasterId, id).remove();
} else if ("3".equals(type)) {
//删除轨检车-》轨道动态几何尺寸容许值差管理值
movementDiferenceManagerService.lambdaUpdate().eq(MovementDiferenceManager::getMovementMasterId, id).remove();
//删除轨检车-》超限记录报告
movementOverReportService.lambdaUpdate().eq(MovementOverReport::getMovementMasterId, id).remove();
//删除轨检车-》区段总结报告
movementSectionReportService.lambdaUpdate().eq(MovementSectionReport::getMovementMasterId, id).remove();
//删除轨检车-》公里总结报告表
movementSummaryReportService.lambdaUpdate().eq(MovementSummaryReport::getMovementMasterId, id).remove();
//删除轨检车-》TQI公里总结报告
movementTqiKilometerReportService.lambdaUpdate().eq(MovementTqiKilometerReport::getMovementMasterId, id).remove();
//删除轨检车-》TQI公里状态评定标准
movementTqiKilometerStandardManagerService.lambdaUpdate().eq(MovementTqiKilometerStandardManager::getMovementMasterId, id).remove();
//删除轨检车-》TQI总结报告
movementTqiReportService.lambdaUpdate().eq(MovementTqiReport::getMovementMasterId, id).remove();
//删除轨检车-》200m区段轨道不平顺质量指数TQI管理标准(单位:mm)
movementTqiStandardManagerService.lambdaUpdate().eq(MovementTqiStandardManager::getMovementMasterId, id).remove();
}
//删除动静态几何尺寸数据
this.service.lambdaUpdate().eq(MovementRecordsMaster::getId, id).remove();
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
......
...@@ -19,4 +19,6 @@ public interface MovementRecordsMasterFace { ...@@ -19,4 +19,6 @@ public interface MovementRecordsMasterFace {
void updateLabourCheckItem(MovementCourse record); void updateLabourCheckItem(MovementCourse record);
void uploadFile(MultipartFile file, String id); void uploadFile(MultipartFile file, String id);
void delete(String id, String type);
} }
...@@ -8,13 +8,12 @@ import com.alibaba.fastjson.JSONObject; ...@@ -8,13 +8,12 @@ import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.jeecg.common.exception.JeecgBootException; 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.*;
import org.jeecg.modules.checkData.entity.MovementCourseInfo;
import org.jeecg.modules.checkData.entity.MovementRecordsMaster;
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.*;
import org.jeecg.modules.checkData.service.IMovementCourseService; import org.jeecg.modules.dynamicStaticAnalysis.entity.AnalysisBatchCheckDataMap;
import org.jeecg.modules.checkData.service.IMovementRecordsMasterService; import org.jeecg.modules.dynamicStaticAnalysis.mapper.AnalysisAlgorithmMapper;
import org.jeecg.modules.dynamicStaticAnalysis.service.IAnalysisBatchCheckDataMapService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -25,6 +24,7 @@ import java.math.BigDecimal; ...@@ -25,6 +24,7 @@ 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.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -39,6 +39,32 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace ...@@ -39,6 +39,32 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace
@Resource @Resource
private IMovementRecordsMasterService movementRecordsMasterService; private IMovementRecordsMasterService movementRecordsMasterService;
@Resource
private IMovementOverReportService movementOverReportService;
@Resource
private IMovementSectionReportService movementSectionReportService;
@Resource
private IMovementSummaryReportService movementSummaryReportService;
@Resource
private IMovementTqiKilometerReportService movementTqiKilometerReportService;
@Resource
private IMovementTqiKilometerStandardManagerService movementTqiKilometerStandardManagerService;
@Resource
private IMovementTqiReportService movementTqiReportService;
@Resource
private IMovementTqiStandardManagerService movementTqiStandardManagerService;
@Resource
private IMovementDiferenceManagerService movementDiferenceManagerService;
@Resource
private IMovementAdditiveInfoService movementAdditiveInfoService;
@Resource
private IRailInspectionEquipmentItemService railInspectionEquipmentItemService;
@Resource
private IRailInspectionEquipmentItemDetailService railInspectionEquipmentItemDetailService;
@Resource
private IAnalysisBatchCheckDataMapService analysisBatchCheckDataMapService;
@Override @Override
public void saveLabourCheckItem(MovementCourse record) { public void saveLabourCheckItem(MovementCourse record) {
...@@ -299,6 +325,56 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace ...@@ -299,6 +325,56 @@ public class MovementRecordsMasterFaceImpl implements MovementRecordsMasterFace
} }
} }
@Override
public void delete(String id, String type) {
List<AnalysisBatchCheckDataMap> existAnalysisList = analysisBatchCheckDataMapService.lambdaQuery()
.eq(AnalysisBatchCheckDataMap::getEkId, id)
.list();
if (ObjectUtil.isNotEmpty(existAnalysisList)) {
Optional<String> optionalStr = existAnalysisList.stream()
.map(AnalysisBatchCheckDataMap::getAnalysisBatchCode)
.reduce((analysisBatchCode1, analysisBatchCode2) -> analysisBatchCode1 + "," + analysisBatchCode2);
String msg = "该数据下关联分析批次:【" + optionalStr.get() + "】";
throw JeecgBootException.error(msg);
}
if ("1".equals(type)) {
//人工静态检查相关
//删除里程详情
movementCourseInfoService.lambdaUpdate().eq(MovementCourseInfo::getMovementMasterId, id).remove();
//删除里程相关
movementCourseService.lambdaUpdate().eq(MovementCourse::getMovementMasterId, id).remove();
} else if ("2".equals(type)) {
// 删除里程
railInspectionEquipmentItemService.lambdaUpdate().eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, id).remove();
// 删除里程明细
railInspectionEquipmentItemDetailService.lambdaUpdate().eq(RailInspectionEquipmentItemDetail::getRailInspectionEquipmentId, id).remove();
} else if ("4".equals(type)) {
//删除添乘仪详情
movementAdditiveInfoService.lambdaUpdate().eq(MovementAdditiveInfo::getMovementMasterId, id).remove();
} else if ("3".equals(type)) {
//删除轨检车-》轨道动态几何尺寸容许值差管理值
movementDiferenceManagerService.lambdaUpdate().eq(MovementDiferenceManager::getMovementMasterId, id).remove();
//删除轨检车-》超限记录报告
movementOverReportService.lambdaUpdate().eq(MovementOverReport::getMovementMasterId, id).remove();
//删除轨检车-》区段总结报告
movementSectionReportService.lambdaUpdate().eq(MovementSectionReport::getMovementMasterId, id).remove();
//删除轨检车-》公里总结报告表
movementSummaryReportService.lambdaUpdate().eq(MovementSummaryReport::getMovementMasterId, id).remove();
//删除轨检车-》TQI公里总结报告
movementTqiKilometerReportService.lambdaUpdate().eq(MovementTqiKilometerReport::getMovementMasterId, id).remove();
//删除轨检车-》TQI公里状态评定标准
movementTqiKilometerStandardManagerService.lambdaUpdate().eq(MovementTqiKilometerStandardManager::getMovementMasterId, id).remove();
//删除轨检车-》TQI总结报告
movementTqiReportService.lambdaUpdate().eq(MovementTqiReport::getMovementMasterId, id).remove();
//删除轨检车-》200m区段轨道不平顺质量指数TQI管理标准(单位:mm)
movementTqiStandardManagerService.lambdaUpdate().eq(MovementTqiStandardManager::getMovementMasterId, id).remove();
}
//删除动静态几何尺寸数据
movementRecordsMasterService.lambdaUpdate().eq(MovementRecordsMaster::getId, id).remove();
}
/** /**
* 当前行处理器 * 当前行处理器
......
...@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.UUIDGenerator; import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.checkData.entity.MovementRecordsMaster; import org.jeecg.modules.checkData.entity.MovementRecordsMaster;
import org.jeecg.modules.checkData.entity.RailInspectionEquipmentItem; import org.jeecg.modules.checkData.entity.RailInspectionEquipmentItem;
...@@ -28,6 +30,7 @@ import java.io.IOException; ...@@ -28,6 +30,7 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -105,7 +108,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -105,7 +108,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
items.add(item); items.add(item);
// 读取item详情 // 读取item详情
int skipRow = readItemDetail(i, titleHeader, item.getId(), rowRecords, itemDetails); int skipRow = readItemDetail(i, titleHeader, item, rowRecords, itemDetails);
i = i + skipRow; i = i + skipRow;
sort++; sort++;
} else { } else {
...@@ -127,7 +130,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -127,7 +130,7 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
} }
} }
private int readItemDetail(int rows, String titleHeader, String itemId, List<List<Object>> rowRecords, List<RailInspectionEquipmentItemDetail> itemDetails) { private int readItemDetail(int rows, String titleHeader, RailInspectionEquipmentItem item, List<List<Object>> rowRecords, List<RailInspectionEquipmentItemDetail> itemDetails) {
// 解析检查项目:1行:跳过2行不解析 // 解析检查项目:1行:跳过2行不解析
List<Object> checkItems = rowRecords.get(rows + 2); List<Object> checkItems = rowRecords.get(rows + 2);
// 解析测点:1行 // 解析测点:1行
...@@ -153,7 +156,8 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -153,7 +156,8 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail(); RailInspectionEquipmentItemDetail itemDetail = new RailInspectionEquipmentItemDetail();
itemDetail.setId(UUIDGenerator.generate()); itemDetail.setId(UUIDGenerator.generate());
itemDetail.setRailInspectionEquipmentItemId(itemId); itemDetail.setRailInspectionEquipmentId(item.getRailInspectionEquipmentId());
itemDetail.setRailInspectionEquipmentItemId(item.getId());
// 检查项目 // 检查项目
String checkItem = checkItems.get(i).toString(); String checkItem = checkItems.get(i).toString();
itemDetail.setCheckItem(checkItem); itemDetail.setCheckItem(checkItem);
...@@ -173,7 +177,17 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp ...@@ -173,7 +177,17 @@ public class RailInspectionEquipmentItemServiceImpl extends ServiceImpl<RailInsp
// 测点值向后偏移一个 // 测点值向后偏移一个
itemDetail.setMeasurePoint(measurePoint + 1); itemDetail.setMeasurePoint(measurePoint + 1);
// 获取登录用户信息
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (ObjectUtil.isNotEmpty(loginUser)) {
itemDetail.setCreateBy(loginUser.getRealname());
itemDetail.setUpdateBy(loginUser.getRealname());
}
itemDetail.setInfoSort(sort++); itemDetail.setInfoSort(sort++);
itemDetail.setDelFlag("0");
itemDetail.setCreateTime(new Date());
itemDetail.setUpdateTime(new Date());
itemDetails.add(itemDetail); itemDetails.add(itemDetail);
} }
......
...@@ -740,7 +740,12 @@ public class AnalysisAlgorithm { ...@@ -740,7 +740,12 @@ public class AnalysisAlgorithm {
// 2.根据分析批次的里程查询出映射单元 // 2.根据分析批次的里程查询出映射单元
List<MovementOverReportUnitDeviceMap> overReportUnitDeviceMaps = new ArrayList<>(); List<MovementOverReportUnitDeviceMap> overReportUnitDeviceMaps = new ArrayList<>();
List<MovementTqiReportUnitDeviceMap> movementTqiReportUnitDeviceMaps = new ArrayList<>(); List<MovementTqiReportUnitDeviceMap> movementTqiReportUnitDeviceMaps = new ArrayList<>();
List<String> unitDeviceIds = new ArrayList<>();
for (Map<String, Object> unitDevice : unitDeviceList) { for (Map<String, Object> unitDevice : unitDeviceList) {
// 添加所有单元ID
String unitDeviceId = Convert.toStr(unitDevice.get("id"));
unitDeviceIds.add(unitDeviceId);
BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage")); BigDecimal startMileage = Convert.toBigDecimal(unitDevice.get("startMileage"));
BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage")); BigDecimal centerMileage = Convert.toBigDecimal(unitDevice.get("centerMileage"));
BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage")); BigDecimal endMileage = Convert.toBigDecimal(unitDevice.get("endMileage"));
...@@ -1054,6 +1059,20 @@ public class AnalysisAlgorithm { ...@@ -1054,6 +1059,20 @@ public class AnalysisAlgorithm {
unitDevice.put("railVehicleCheckScoreList", scoreList); unitDevice.put("railVehicleCheckScoreList", scoreList);
} }
// 3.先删除旧的关联关系,在新增
movementOverReportUnitDeviceMapService.lambdaUpdate()
.in(MovementOverReportUnitDeviceMap::getUnitId, unitDeviceIds)
.remove();
movementOverReportUnitDeviceMapService.saveBatch(overReportUnitDeviceMaps);
movementTqiReportUnitDeviceMapService.lambdaUpdate()
.in(MovementTqiReportUnitDeviceMap::getUnitId, unitDeviceIds)
.remove();
movementTqiReportUnitDeviceMapService.saveBatch(movementTqiReportUnitDeviceMaps);
} }
/** /**
......
package org.jeecg.modules.dynamicStaticAnalysis.controller; package org.jeecg.modules.dynamicStaticAnalysis.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -42,7 +43,9 @@ public class AnalysisBatchUnitDeviceController extends JeecgController<AnalysisB ...@@ -42,7 +43,9 @@ public class AnalysisBatchUnitDeviceController extends JeecgController<AnalysisB
@PostMapping(value = "/listRecord") @PostMapping(value = "/listRecord")
public Result<IPage<AnalysisBatchUnitDeviceVO>> listRecord(@RequestBody AnalysisBatchUnitDeviceDTO dto) { public Result<IPage<AnalysisBatchUnitDeviceVO>> listRecord(@RequestBody AnalysisBatchUnitDeviceDTO dto) {
Page<AnalysisBatchUnitDeviceVO> pageData = new Page<>(dto.getPageNo(), dto.getPageSize()); Page<AnalysisBatchUnitDeviceVO> pageData = new Page<>(dto.getPageNo(), dto.getPageSize());
if (ObjectUtil.isNotEmpty(dto.getUnitTypeList()) && ObjectUtil.isNotEmpty(dto.getGradeJudgeList())) {
pageData = this.service.listRecord(pageData, dto); pageData = this.service.listRecord(pageData, dto);
}
return Result.OK(pageData); return Result.OK(pageData);
......
...@@ -300,7 +300,7 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub ...@@ -300,7 +300,7 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
message = "选中" + totalNum + "条数据已删除数据" + successNum + "条"; message = "选中" + totalNum + "条数据已删除数据" + successNum + "条";
if (totalNum - successNum > 0) { if (totalNum - successNum > 0) {
message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是线路下面有关联设备故不能被删除"; message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是区间下面有关联数据故不能被删除";
} }
return Result.batchDelete(message); return Result.batchDelete(message);
} }
......
package org.jeecg.modules.system.controller; package org.jeecg.modules.system.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.util.SqlInjectionUtil; import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.mapper.SysDictMapper; import org.jeecg.modules.system.mapper.SysDictMapper;
import org.jeecg.modules.system.model.DuplicateCheckVo; import org.jeecg.modules.system.model.DuplicateCheckVo;
import org.jeecg.modules.system.security.DictQueryBlackListHandler; import org.jeecg.modules.system.security.DictQueryBlackListHandler;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -25,7 +21,7 @@ import io.swagger.annotations.Api; ...@@ -25,7 +21,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.*;
/** /**
* @Title: DuplicateCheckAction * @Title: DuplicateCheckAction
...@@ -40,14 +36,59 @@ import java.util.List; ...@@ -40,14 +36,59 @@ import java.util.List;
@Api(tags = "重复校验") @Api(tags = "重复校验")
public class DuplicateCheckController { public class DuplicateCheckController {
@Autowired @Resource
SysDictMapper sysDictMapper; private SysDictMapper sysDictMapper;
@Autowired @Resource
DictQueryBlackListHandler dictQueryBlackListHandler; private DictQueryBlackListHandler dictQueryBlackListHandler;
@Autowired @RequestMapping(value = "/checks", method = RequestMethod.GET)
private ISysUserService sysUserService; @ApiOperation("重复校验接口")
public Result<String> doDuplicateChecks(HttpServletRequest request) {
Map<String, String[]> requestParameterMap = request.getParameterMap();
// 如果参数为空或者表名不传
if (requestParameterMap.size() == 0 || ObjectUtil.isEmpty(requestParameterMap.get("tableName"))) {
Result<String> rs = new Result<>();
rs.setCode(500);
rs.setSuccess(true);
rs.setMessage("数据为空,不作处理!");
return rs;
}
Map<String, String> map = new LinkedHashMap<>();
StringBuilder checkSql = new StringBuilder();
String[] sqlInjCheckValues = new String[requestParameterMap.size()];
int i = 0;
for (Map.Entry<String, String[]> entry : requestParameterMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue()[0];
if (ObjectUtil.isEmpty(value)) {
continue;
}
sqlInjCheckValues[i++] = value;
checkSql.append(value).append(SymbolConstant.COMMA);
map.put(key, value);
}
// SQL注入校验(只限制非法串改数据库)
SqlInjectionUtil.filterContent(sqlInjCheckValues);
if (!dictQueryBlackListHandler.isPass(checkSql.toString())) {
return Result.error(dictQueryBlackListHandler.getError());
}
// 验证参数
Long num = sysDictMapper.duplicateCheckCountSqlByPrams(map);
if (num == null || num == 0) {
// 该值可用
return Result.ok("该值可用!");
} else {
// 该值不可用
log.info("该值不可用,系统中已存在!");
return Result.error("");
}
}
/** /**
* 校验数据是否在系统中是否存在 * 校验数据是否在系统中是否存在
...@@ -93,40 +134,11 @@ public class DuplicateCheckController { ...@@ -93,40 +134,11 @@ public class DuplicateCheckController {
} else { } else {
// 该值不可用 // 该值不可用
log.info("该值不可用,系统中已存在!"); log.info("该值不可用,系统中已存在!");
// return Result.error("该值不可用,系统中已存在!");
return Result.error(""); return Result.error("");
} }
} }
/** /**
* 校验用户相关信息是否存在
*
* @return
*/
// @RequestMapping(value = "/checkUser", method = RequestMethod.GET)
// @ApiOperation("校验用户相关信息是否存在")
// public Result<String> checkUser(@ApiParam(name = "需要校验的参数", required = true) String name,@ApiParam(name = "类型", required = true) String type) {
// LambdaQueryWrapper<SysUser> lambdaQuery = Wrappers.lambdaQuery();
// if("1".equals(type)){
// lambdaQuery.eq(SysUser::getUsername, name);
// }
// if("2".equals(type)){
// lambdaQuery.eq(SysUser::getRealname, name);
// }
// if("3".equals(type)){
// lambdaQuery.eq(SysUser::getWorkNo, name);
// }
// if("4".equals(type)){
// lambdaQuery.eq(SysUser::getPhone, name);
// }
// lambdaQuery.eq(SysUser::getDelFlag, 0);
// List<SysUser> list = sysUserService.list(lambdaQuery);
// if (list != null && list.size() > 0) {
// return Result.error("参数已存在");
// }
// return Result.ok("");
// }
/**
* VUEN-2584【issue】平台sql注入漏洞几个问题 * VUEN-2584【issue】平台sql注入漏洞几个问题
* 部分特殊函数 可以将查询结果混夹在错误信息中,导致数据库的信息暴露 * 部分特殊函数 可以将查询结果混夹在错误信息中,导致数据库的信息暴露
* *
......
...@@ -29,6 +29,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -29,6 +29,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 重复检查SQL * 重复检查SQL
*
* @param duplicateCheckVo * @param duplicateCheckVo
* @return * @return
*/ */
...@@ -37,6 +38,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -37,6 +38,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 重复校验 sql语句 * 重复校验 sql语句
*
* @param duplicateCheckVo * @param duplicateCheckVo
* @return * @return
*/ */
...@@ -45,6 +47,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -45,6 +47,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 通过字典code获取字典数据 * 通过字典code获取字典数据
*
* @param code 字典code * @param code 字典code
* @return List<DictModel> * @return List<DictModel>
*/ */
...@@ -52,6 +55,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -52,6 +55,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询有效的数据字典项 * 查询有效的数据字典项
*
* @param code * @param code
* @return * @return
*/ */
...@@ -68,16 +72,18 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -68,16 +72,18 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 通过查询指定table的 text code 获取字典 * 通过查询指定table的 text code 获取字典
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
* @return List<DictModel> * @return List<DictModel>
*/ */
@Deprecated @Deprecated
public List<DictModel> queryTableDictItemsByCode(@Param("table") String table,@Param("text") String text,@Param("code") String code); public List<DictModel> queryTableDictItemsByCode(@Param("table") String table, @Param("text") String text, @Param("code") String code);
/** /**
* 通过查询指定table的 text code 获取字典(指定查询条件) * 通过查询指定table的 text code 获取字典(指定查询条件)
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
...@@ -85,29 +91,32 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -85,29 +91,32 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
* @return List<DictModel> * @return List<DictModel>
*/ */
@Deprecated @Deprecated
public List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("filterSql") String filterSql); public List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
/** /**
* 通过查询指定table的 text code 获取字典 * 通过查询指定table的 text code 获取字典
*
* @param table * @param table
* @param key * @param key
* @param value * @param value
* @return List<Map<String,String>> * @return List<Map < String, String>>
*/ */
@Deprecated @Deprecated
@Select("select ${key} as \"label\",${value} as \"value\" from ${table}") @Select("select ${key} as \"label\",${value} as \"value\" from ${table}")
public List<Map<String,String>> getDictByTableNgAlain(@Param("table") String table, @Param("key") String key, @Param("value") String value); public List<Map<String, String>> getDictByTableNgAlain(@Param("table") String table, @Param("key") String key, @Param("value") String value);
/** /**
* 通过字典code获取字典数据 * 通过字典code获取字典数据
*
* @param code * @param code
* @param key * @param key
* @return * @return
*/ */
public String queryDictTextByKey(@Param("code") String code,@Param("key") String key); public String queryDictTextByKey(@Param("code") String code, @Param("key") String key);
/** /**
* 可通过多个字典code查询翻译文本 * 可通过多个字典code查询翻译文本
*
* @param dictCodeList 多个字典code * @param dictCodeList 多个字典code
* @param keys 数据列表 * @param keys 数据列表
* @return * @return
...@@ -116,6 +125,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -116,6 +125,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 通过查询指定table的 text code key 获取字典值 * 通过查询指定table的 text code key 获取字典值
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
...@@ -123,7 +133,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -123,7 +133,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
* @return String * @return String
*/ */
@Deprecated @Deprecated
public String queryTableDictTextByKey(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("key") String key); public String queryTableDictTextByKey(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("key") String key);
// /** // /**
// * 通过查询指定table的 text code key 获取字典值,可批量查询 // * 通过查询指定table的 text code key 获取字典值,可批量查询
...@@ -150,12 +160,14 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -150,12 +160,14 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询所有部门 作为字典信息 id -->value,departName -->text * 查询所有部门 作为字典信息 id -->value,departName -->text
*
* @return * @return
*/ */
public List<DictModel> queryAllDepartBackDictModel(); public List<DictModel> queryAllDepartBackDictModel();
/** /**
* 查询所有用户 作为字典信息 username -->value,realname -->text * 查询所有用户 作为字典信息 username -->value,realname -->text
*
* @return * @return
*/ */
public List<DictModel> queryAllUserBackDictModel(); public List<DictModel> queryAllUserBackDictModel();
...@@ -185,6 +197,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -185,6 +197,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 根据表名、显示字段名、存储字段名 查询树 * 根据表名、显示字段名、存储字段名 查询树
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
...@@ -195,10 +208,11 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -195,10 +208,11 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
* @return * @return
*/ */
@Deprecated @Deprecated
List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField,@Param("converIsLeafVal") int converIsLeafVal); List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("pidField") String pidField, @Param("pid") String pid, @Param("hasChildField") String hasChildField, @Param("converIsLeafVal") int converIsLeafVal);
/** /**
* 删除 * 删除
*
* @param id * @param id
*/ */
@Select("delete from sys_dict where id = #{id}") @Select("delete from sys_dict where id = #{id}")
...@@ -206,6 +220,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -206,6 +220,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询被逻辑删除的数据 * 查询被逻辑删除的数据
*
* @return * @return
*/ */
@Select("select * from sys_dict where del_flag = 1") @Select("select * from sys_dict where del_flag = 1")
...@@ -213,6 +228,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -213,6 +228,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 修改状态值 * 修改状态值
*
* @param delFlag * @param delFlag
* @param id * @param id
*/ */
...@@ -222,6 +238,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -222,6 +238,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 分页查询字典表数据 * 分页查询字典表数据
*
* @param page * @param page
* @param query * @param query
* @return * @return
...@@ -232,6 +249,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -232,6 +249,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询 字典表数据 支持查询条件 分页 * 查询 字典表数据 支持查询条件 分页
*
* @param page * @param page
* @param table * @param table
* @param text * @param text
...@@ -244,6 +262,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -244,6 +262,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询 字典表数据 支持查询条件 查询所有 * 查询 字典表数据 支持查询条件 查询所有
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
...@@ -255,6 +274,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -255,6 +274,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 查询字典表的数据 * 查询字典表的数据
*
* @param table 表名 * @param table 表名
* @param text 显示字段名 * @param text 显示字段名
* @param code 存储字段名 * @param code 存储字段名
...@@ -266,10 +286,13 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -266,10 +286,13 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 根据应用id获取字典列表和详情 * 根据应用id获取字典列表和详情
*
* @param lowAppId * @param lowAppId
* @param tenantId * @param tenantId
* @return * @return
*/ */
@InterceptorIgnore(tenantLine = "true") @InterceptorIgnore(tenantLine = "true")
List<SysDict> getDictListByLowAppId(@Param("lowAppId") String lowAppId, @Param("tenantId") Integer tenantId); List<SysDict> getDictListByLowAppId(@Param("lowAppId") String lowAppId, @Param("tenantId") Integer tenantId);
Long duplicateCheckCountSqlByPrams(@Param("map") Map<String, String> map);
} }
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
<!-- 通过字典code获取字典数据 --> <!-- 通过字典code获取字典数据 -->
<select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
select s.item_value as "value",s.item_text as "text" from sys_dict_item s select s.item_value as "value", s.item_text as "text"
from sys_dict_item s
where dict_id = (select id from sys_dict where dict_code = #{code}) where dict_id = (select id from sys_dict where dict_code = #{code})
order by s.sort_order asc, s.create_time DESC; order by s.sort_order asc, s.create_time DESC;
</select> </select>
<!-- 通过字典code获取有效的字典数据项 --> <!-- 通过字典code获取有效的字典数据项 -->
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
select s.item_value as "value",s.item_text as "text" from sys_dict_item s select s.item_value as "value", s.item_text as "text"
from sys_dict_item s
where dict_id = (select id from sys_dict where dict_code = #{code}) where dict_id = (select id from sys_dict where dict_code = #{code})
and s.status = 1 and s.status = 1
order by s.sort_order asc, s.create_time DESC; order by s.sort_order asc, s.create_time DESC;
...@@ -36,7 +38,8 @@ ...@@ -36,7 +38,8 @@
<!-- 通过字典code获取字典数据 --> <!-- 通过字典code获取字典数据 -->
<select id="queryDictTextByKey" parameterType="String" resultType="String"> <select id="queryDictTextByKey" parameterType="String" resultType="String">
select s.item_text from sys_dict_item s select s.item_text
from sys_dict_item s
where s.dict_id = (select id from sys_dict where dict_code = #{code}) where s.dict_id = (select id from sys_dict where dict_code = #{code})
and s.item_value = #{key} and s.item_value = #{key}
</select> </select>
...@@ -64,11 +67,13 @@ ...@@ -64,11 +67,13 @@
<!--通过查询指定table的 text code 获取字典--> <!--通过查询指定table的 text code 获取字典-->
<select id="queryTableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryTableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table} select ${text} as "text", ${code} as "value"
from ${table}
</select> </select>
<!--通过查询指定table的 text code 获取字典(指定查询条件)--> <!--通过查询指定table的 text code 获取字典(指定查询条件)-->
<select id="queryTableDictItemsByCodeAndFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryTableDictItemsByCodeAndFilter" parameterType="String"
resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table} select ${text} as "text",${code} as "value" from ${table}
<if test="filterSql != null and filterSql != ''"> <if test="filterSql != null and filterSql != ''">
where ${filterSql} where ${filterSql}
...@@ -77,7 +82,9 @@ ...@@ -77,7 +82,9 @@
<!--通过查询指定table的 text code key 获取字典值--> <!--通过查询指定table的 text code key 获取字典值-->
<select id="queryTableDictTextByKey" parameterType="String" resultType="String"> <select id="queryTableDictTextByKey" parameterType="String" resultType="String">
select ${text} as "text" from ${table} where ${code}= #{key} select ${text} as "text"
from ${table}
where ${code} = #{key}
</select> </select>
<!--通过查询指定table的 text code key 获取字典值,可批量查询 <!--通过查询指定table的 text code key 获取字典值,可批量查询
...@@ -98,23 +105,34 @@ ...@@ -98,23 +105,34 @@
</select>--> </select>-->
<!-- 重复校验 sql语句 --> <!-- 重复校验 sql语句 -->
<select id="duplicateCheckCountSql" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo"> <select id="duplicateCheckCountSql" resultType="Long"
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} and id &lt;&gt; #{dataId} parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*)
FROM ${tableName}
WHERE ${fieldName} = #{fieldVal}
and id &lt;&gt; #{dataId}
</select> </select>
<!-- 重复校验 sql语句 --> <!-- 重复校验 sql语句 -->
<select id="duplicateCheckCountSqlNoDataId" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo"> <select id="duplicateCheckCountSqlNoDataId" resultType="Long"
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*)
FROM ${tableName}
WHERE ${fieldName} = #{fieldVal}
</select> </select>
<!-- 查询部门信息 作为字典数据 --> <!-- 查询部门信息 作为字典数据 -->
<select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
select id as "value",depart_name as "text" from sys_depart where del_flag = '0' select id as "value", depart_name as "text"
from sys_depart
where del_flag = '0'
</select> </select>
<!-- 查询用户信息 作为字典数据 --> <!-- 查询用户信息 作为字典数据 -->
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
select username as "value",realname as "text" from sys_user where del_flag = '0' select username as "value", realname as "text"
from sys_user
where del_flag = '0'
</select> </select>
<!--通过查询指定table的 text code 获取字典数据,且支持关键字查询 <!--通过查询指定table的 text code 获取字典数据,且支持关键字查询
...@@ -154,7 +172,7 @@ ...@@ -154,7 +172,7 @@
</if> </if>
<if test="query!= null"> <if test="query!= null">
1 = 1 1 = 1
<foreach collection="query.entrySet()" item="value" index="key" > <foreach collection="query.entrySet()" item="value" index="key">
<choose> <choose>
<when test="key == 'tenant_id'"> <when test="key == 'tenant_id'">
and tenant_id = #{value} and tenant_id = #{value}
...@@ -210,7 +228,8 @@ ...@@ -210,7 +228,8 @@
<!-- 查询字典表的数据 支持设置过滤条件、设置存储值作为in查询条件 --> <!-- 查询字典表的数据 支持设置过滤条件、设置存储值作为in查询条件 -->
<select id="queryTableDictByKeysAndFilterSql" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryTableDictByKeysAndFilterSql" parameterType="String"
resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text", ${code} as "value" from ${table} where ${code} IN ( select ${text} as "text", ${code} as "value" from ${table} where ${code} IN (
<foreach item="key" collection="codeValues" separator=","> <foreach item="key" collection="codeValues" separator=",">
#{key} #{key}
...@@ -223,12 +242,24 @@ ...@@ -223,12 +242,24 @@
<!--根据应用id获取字典列表和详情--> <!--根据应用id获取字典列表和详情-->
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict"> <select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
select id,dict_name,dict_code from sys_dict select id, dict_name, dict_code
where from sys_dict
del_flag = 0 where del_flag = 0
and low_app_id = #{lowAppId} and low_app_id = #{lowAppId}
and tenant_id = #{tenantId} and tenant_id = #{tenantId}
</select> </select>
<select id="duplicateCheckCountSqlByPrams" resultType="java.lang.Long">
SELECT COUNT(*) FROM ${map.tableName} WHERE 1=1
<foreach collection="map" index="key" item="value">
<if test="key != 'tableName' and key != 'id'">
AND ${key} = #{value}
</if>
<if test="key == 'id'">
AND ${key} &lt;&gt; #{value}
</if>
</foreach>
</select>
</mapper> </mapper>
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