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());
pageData = this.service.listRecord(pageData, dto); if (ObjectUtil.isNotEmpty(dto.getUnitTypeList()) && ObjectUtil.isNotEmpty(dto.getGradeJudgeList())) {
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注入漏洞几个问题
* 部分特殊函数 可以将查询结果混夹在错误信息中,导致数据库的信息暴露 * 部分特殊函数 可以将查询结果混夹在错误信息中,导致数据库的信息暴露
* *
......
...@@ -26,104 +26,114 @@ import java.util.Map; ...@@ -26,104 +26,114 @@ import java.util.Map;
* @since 2018-12-28 * @since 2018-12-28
*/ */
public interface SysDictMapper extends BaseMapper<SysDict> { public interface SysDictMapper extends BaseMapper<SysDict> {
/** /**
* 重复检查SQL * 重复检查SQL
*
* @param duplicateCheckVo * @param duplicateCheckVo
* @return * @return
*/ */
@Deprecated @Deprecated
public Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo); public Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo);
/** /**
* 重复校验 sql语句 * 重复校验 sql语句
*
* @param duplicateCheckVo * @param duplicateCheckVo
* @return * @return
*/ */
@Deprecated @Deprecated
public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo); public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);
/** /**
* 通过字典code获取字典数据 * 通过字典code获取字典数据
*
* @param code 字典code * @param code 字典code
* @return List<DictModel> * @return List<DictModel>
*/ */
public List<DictModel> queryDictItemsByCode(@Param("code") String code); public List<DictModel> queryDictItemsByCode(@Param("code") String code);
/** /**
* 查询有效的数据字典项 * 查询有效的数据字典项
* @param code *
* @return * @param code
*/ * @return
List<DictModel> queryEnableDictItemsByCode(@Param("code") String code); */
List<DictModel> queryEnableDictItemsByCode(@Param("code") String code);
/** /**
* 通过多个字典code获取字典数据 * 通过多个字典code获取字典数据
* *
* @param dictCodeList * @param dictCodeList
* @return * @return
*/ */
public List<DictModelMany> queryDictItemsByCodeList(@Param("dictCodeList") List<String> dictCodeList); public List<DictModelMany> queryDictItemsByCodeList(@Param("dictCodeList") List<String> dictCodeList);
/** /**
* 通过查询指定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
* @param filterSql * @param filterSql
* @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 keys 数据列表 * @param dictCodeList 多个字典code
* @return * @param keys 数据列表
*/ * @return
List<DictModelMany> queryManyDictByKeys(@Param("dictCodeList") List<String> dictCodeList, @Param("keys") List<String> keys); */
List<DictModelMany> queryManyDictByKeys(@Param("dictCodeList") List<String> dictCodeList, @Param("keys") List<String> keys);
/** /**
* 通过查询指定table的 text code key 获取字典值 * 通过查询指定table的 text code key 获取字典值
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
* @param key * @param key
* @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 获取字典值,可批量查询
...@@ -148,18 +158,20 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -148,18 +158,20 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
//// @Deprecated //// @Deprecated
//// public List<DictModel> queryTableictByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyArray") String[] keyArray); //// public List<DictModel> queryTableictByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyArray") String[] keyArray);
/** /**
* 查询所有部门 作为字典信息 id -->value,departName -->text * 查询所有部门 作为字典信息 id -->value,departName -->text
* @return *
*/ * @return
public List<DictModel> queryAllDepartBackDictModel(); */
public List<DictModel> queryAllDepartBackDictModel();
/**
* 查询所有用户 作为字典信息 username -->value,realname -->text /**
* @return * 查询所有用户 作为字典信息 username -->value,realname -->text
*/ *
public List<DictModel> queryAllUserBackDictModel(); * @return
*/
public List<DictModel> queryAllUserBackDictModel();
// /** // /**
// * 通过关键字查询出字典表 // * 通过关键字查询出字典表
// * @param table // * @param table
...@@ -183,93 +195,104 @@ public interface SysDictMapper extends BaseMapper<SysDict> { ...@@ -183,93 +195,104 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
// */ // */
// //IPage<DictModel> queryTableDictItems(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyword") String keyword); // //IPage<DictModel> queryTableDictItems(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyword") String keyword);
/** /**
* 根据表名、显示字段名、存储字段名 查询树 * 根据表名、显示字段名、存储字段名 查询树
* @param table *
* @param text * @param table
* @param code * @param text
* @param pid * @param code
* @param hasChildField * @param pid
* @param hasChildField
* @param query * @param query
* @param pidField * @param pidField
* @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}") */
public void deleteOneById(@Param("id") String id); @Select("delete from sys_dict where id = #{id}")
public void deleteOneById(@Param("id") String id);
/**
* 查询被逻辑删除的数据 /**
* @return * 查询被逻辑删除的数据
*/ *
@Select("select * from sys_dict where del_flag = 1") * @return
public List<SysDict> queryDeleteList(); */
@Select("select * from sys_dict where del_flag = 1")
/** public List<SysDict> queryDeleteList();
* 修改状态值
* @param delFlag /**
* @param id * 修改状态值
*/ *
@Update("update sys_dict set del_flag = #{flag,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR}") * @param delFlag
public void updateDictDelFlag(@Param("flag") int delFlag, @Param("id") String id); * @param id
*/
@Update("update sys_dict set del_flag = #{flag,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR}")
/** public void updateDictDelFlag(@Param("flag") int delFlag, @Param("id") String id);
* 分页查询字典表数据
* @param page
* @param query /**
* @return * 分页查询字典表数据
*/ *
@Deprecated * @param page
public Page<DictModel> queryDictTablePageList(Page page, @Param("query") DictQuery query); * @param query
* @return
*/
/** @Deprecated
* 查询 字典表数据 支持查询条件 分页 public Page<DictModel> queryDictTablePageList(Page page, @Param("query") DictQuery query);
* @param page
* @param table
* @param text /**
* @param code * 查询 字典表数据 支持查询条件 分页
* @param filterSql *
* @return * @param page
*/ * @param table
@Deprecated * @param text
IPage<DictModel> queryTableDictWithFilter(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql); * @param code
* @param filterSql
/** * @return
* 查询 字典表数据 支持查询条件 查询所有 */
* @param table @Deprecated
* @param text IPage<DictModel> queryTableDictWithFilter(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
* @param code
* @param filterSql /**
* @return * 查询 字典表数据 支持查询条件 查询所有
*/ *
@Deprecated * @param table
List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql); * @param text
* @param code
/** * @param filterSql
* 查询字典表的数据 * @return
* @param table 表名 */
* @param text 显示字段名 @Deprecated
* @param code 存储字段名 List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
* @param filterSql 条件sql
* @param codeValues 存储字段值 作为查询条件in /**
* @return * 查询字典表的数据
*/ *
List<DictModel> queryTableDictByKeysAndFilterSql(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql, @Param("codeValues") List<String> codeValues); * @param table 表名
* @param text 显示字段名
/** * @param code 存储字段名
* 根据应用id获取字典列表和详情 * @param filterSql 条件sql
* @param lowAppId * @param codeValues 存储字段值 作为查询条件in
* @param tenantId * @return
* @return */
*/ List<DictModel> queryTableDictByKeysAndFilterSql(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql, @Param("codeValues") List<String> codeValues);
@InterceptorIgnore(tenantLine = "true")
/**
* 根据应用id获取字典列表和详情
*
* @param lowAppId
* @param tenantId
* @return
*/
@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);
} }
...@@ -2,233 +2,264 @@ ...@@ -2,233 +2,264 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.system.mapper.SysDictMapper"> <mapper namespace="org.jeecg.modules.system.mapper.SysDictMapper">
<!-- 通过字典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"
where dict_id = (select id from sys_dict where dict_code = #{code}) from sys_dict_item s
order by s.sort_order asc, s.create_time DESC; where dict_id = (select id from sys_dict where dict_code = #{code})
</select> order by s.sort_order asc, s.create_time DESC;
</select>
<!-- 通过字典code获取有效的字典数据项 -->
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <!-- 通过字典code获取有效的字典数据项 -->
select s.item_value as "value",s.item_text as "text" from sys_dict_item s <select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
where dict_id = (select id from sys_dict where dict_code = #{code}) select s.item_value as "value", s.item_text as "text"
and s.status = 1 from sys_dict_item s
order by s.sort_order asc, s.create_time DESC; where dict_id = (select id from sys_dict where dict_code = #{code})
</select> and s.status = 1
order by s.sort_order asc, s.create_time DESC;
<!-- 通过多个字典code获取字典数据 --> </select>
<select id="queryDictItemsByCodeList" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany">
SELECT <!-- 通过多个字典code获取字典数据 -->
dict.dict_code, <select id="queryDictItemsByCodeList" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany">
item.item_text AS "text", SELECT
item.item_value AS "value" dict.dict_code,
FROM item.item_text AS "text",
sys_dict_item item item.item_value AS "value"
INNER JOIN sys_dict dict ON dict.id = item.dict_id FROM
WHERE dict.dict_code IN ( sys_dict_item item
<foreach item="dictCode" collection="dictCodeList" separator=","> INNER JOIN sys_dict dict ON dict.id = item.dict_id
#{dictCode} WHERE dict.dict_code IN (
</foreach> <foreach item="dictCode" collection="dictCodeList" separator=",">
) #{dictCode}
ORDER BY item.sort_order ASC </foreach>
</select> )
ORDER BY item.sort_order ASC
<!-- 通过字典code获取字典数据 --> </select>
<select id="queryDictTextByKey" parameterType="String" resultType="String">
select s.item_text from sys_dict_item s <!-- 通过字典code获取字典数据 -->
where s.dict_id = (select id from sys_dict where dict_code = #{code}) <select id="queryDictTextByKey" parameterType="String" resultType="String">
and s.item_value = #{key} select s.item_text
</select> from sys_dict_item s
where s.dict_id = (select id from sys_dict where dict_code = #{code})
<!-- 通过字典code获取字典数据,可批量查询 --> and s.item_value = #{key}
<select id="queryManyDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany"> </select>
SELECT
dict.dict_code, <!-- 通过字典code获取字典数据,可批量查询 -->
item.item_text AS "text", <select id="queryManyDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany">
item.item_value AS "value" SELECT
FROM dict.dict_code,
sys_dict_item item item.item_text AS "text",
INNER JOIN sys_dict dict ON dict.id = item.dict_id item.item_value AS "value"
WHERE dict.dict_code IN ( FROM
<foreach item="dictCode" collection="dictCodeList" separator=","> sys_dict_item item
#{dictCode} INNER JOIN sys_dict dict ON dict.id = item.dict_id
</foreach> WHERE dict.dict_code IN (
) <foreach item="dictCode" collection="dictCodeList" separator=",">
AND item.item_value IN ( #{dictCode}
<foreach item="key" collection="keys" separator=","> </foreach>
#{key} )
</foreach> AND item.item_value IN (
) <foreach item="key" collection="keys" separator=",">
</select> #{key}
</foreach>
<!--通过查询指定table的 text code 获取字典--> )
<select id="queryTableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> </select>
select ${text} as "text",${code} as "value" from ${table}
</select> <!--通过查询指定table的 text code 获取字典-->
<select id="queryTableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
<!--通过查询指定table的 text code 获取字典(指定查询条件)--> select ${text} as "text", ${code} as "value"
<select id="queryTableDictItemsByCodeAndFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> from ${table}
select ${text} as "text",${code} as "value" from ${table} </select>
<if test="filterSql != null and filterSql != ''">
where ${filterSql} <!--通过查询指定table的 text code 获取字典(指定查询条件)-->
</if> <select id="queryTableDictItemsByCodeAndFilter" parameterType="String"
</select> resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table}
<!--通过查询指定table的 text code key 获取字典值--> <if test="filterSql != null and filterSql != ''">
<select id="queryTableDictTextByKey" parameterType="String" resultType="String"> where ${filterSql}
select ${text} as "text" from ${table} where ${code}= #{key} </if>
</select> </select>
<!--通过查询指定table的 text code key 获取字典值,可批量查询 <!--通过查询指定table的 text code key 获取字典值-->
<select id="queryTableDictTextByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <select id="queryTableDictTextByKey" parameterType="String" resultType="String">
select ${text} as "text", ${code} as "value" from ${table} where ${code} IN ( select ${text} as "text"
<foreach item="key" collection="keys" separator=","> from ${table}
#{key} where ${code} = #{key}
</foreach> </select>
)
</select>--> <!--通过查询指定table的 text code key 获取字典值,可批量查询
<select id="queryTableDictTextByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
<!--通过查询指定table的 text code key 获取字典值,包含value select ${text} as "text", ${code} as "value" from ${table} where ${code} IN (
<select id="queryTableDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <foreach item="key" collection="keys" separator=",">
select ${text} as "text", ${code} as "value" from ${table} where ${code} in #{key}
<foreach item="key" collection="keyArray" open="(" separator="," close=")"> </foreach>
#{key} )
</foreach> </select>-->
</select>-->
<!--通过查询指定table的 text code key 获取字典值,包含value
<!-- 重复校验 sql语句 --> <select id="queryTableDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
<select id="duplicateCheckCountSql" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo"> select ${text} as "text", ${code} as "value" from ${table} where ${code} in
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} and id &lt;&gt; #{dataId} <foreach item="key" collection="keyArray" open="(" separator="," close=")">
</select> #{key}
</foreach>
<!-- 重复校验 sql语句 --> </select>-->
<select id="duplicateCheckCountSqlNoDataId" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} <!-- 重复校验 sql语句 -->
</select> <select id="duplicateCheckCountSql" resultType="Long"
parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
<!-- 查询部门信息 作为字典数据 --> SELECT COUNT(*)
<select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel"> FROM ${tableName}
select id as "value",depart_name as "text" from sys_depart where del_flag = '0' WHERE ${fieldName} = #{fieldVal}
</select> and id &lt;&gt; #{dataId}
</select>
<!-- 查询用户信息 作为字典数据 -->
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel"> <!-- 重复校验 sql语句 -->
select username as "value",realname as "text" from sys_user where del_flag = '0' <select id="duplicateCheckCountSqlNoDataId" resultType="Long"
</select> parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*)
<!--通过查询指定table的 text code 获取字典数据,且支持关键字查询 FROM ${tableName}
<select id="queryTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> WHERE ${fieldName} = #{fieldVal}
select ${text} as "text",${code} as "value" from ${table} where ${text} like #{keyword} </select>
</select> -->
<!-- 查询部门信息 作为字典数据 -->
<!-- 根据表名、显示字段名、存储字段名、父ID查询树 --> <select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
<select id="queryTreeList" parameterType="Object" resultType="org.jeecg.modules.system.model.TreeSelectModel"> select id as "value", depart_name as "text"
select ${text} as "title", from sys_depart
${code} as "key", where del_flag = '0'
<!-- udapte-begin-author:taoyan date:20211115 for: 自定义树控件只显示父节点,子节点无法展开 (此处还原不可再改) /issues/I4HZAL --> </select>
<if test="hasChildField != null and hasChildField != ''">
<choose> <!-- 查询用户信息 作为字典数据 -->
<when test="converIsLeafVal!=null and converIsLeafVal==1"> <select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
(case when ${hasChildField} = '1' then 0 else 1 end) as isLeaf, select username as "value", realname as "text"
</when> from sys_user
<otherwise> where del_flag = '0'
${hasChildField} as isLeaf, </select>
</otherwise>
</choose> <!--通过查询指定table的 text code 获取字典数据,且支持关键字查询
</if> <select id="queryTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
<!-- udapte-end-author:taoyan date:20211115 for: 自定义树控件只显示父节点,子节点无法展开 (此处还原不可再改) /issues/I4HZAL --> select ${text} as "text",${code} as "value" from ${table} where ${text} like #{keyword}
${pidField} as parentId </select> -->
from ${table}
where <!-- 根据表名、显示字段名、存储字段名、父ID查询树 -->
<!-- udapte-begin-author:sunjianlei date:20220110 for: 【JTC-597】自定义树查询条件查不出数据 --> <select id="queryTreeList" parameterType="Object" resultType="org.jeecg.modules.system.model.TreeSelectModel">
<if test="query == null"> select ${text} as "title",
<choose> ${code} as "key",
<when test="pid != null and pid != ''"> <!-- udapte-begin-author:taoyan date:20211115 for: 自定义树控件只显示父节点,子节点无法展开 (此处还原不可再改) /issues/I4HZAL -->
${pidField} = #{pid} <if test="hasChildField != null and hasChildField != ''">
</when> <choose>
<otherwise> <when test="converIsLeafVal!=null and converIsLeafVal==1">
(${pidField} = '' OR ${pidField} IS NULL) (case when ${hasChildField} = '1' then 0 else 1 end) as isLeaf,
</otherwise> </when>
</choose> <otherwise>
</if> ${hasChildField} as isLeaf,
<if test="query!= null"> </otherwise>
1 = 1 </choose>
<foreach collection="query.entrySet()" item="value" index="key" > </if>
<choose> <!-- udapte-end-author:taoyan date:20211115 for: 自定义树控件只显示父节点,子节点无法展开 (此处还原不可再改) /issues/I4HZAL -->
<when test="key == 'tenant_id'"> ${pidField} as parentId
and tenant_id = #{value} from ${table}
</when> where
<otherwise> <!-- udapte-begin-author:sunjianlei date:20220110 for: 【JTC-597】自定义树查询条件查不出数据 -->
and ${key} LIKE #{value} <if test="query == null">
</otherwise> <choose>
</choose> <when test="pid != null and pid != ''">
</foreach> ${pidField} = #{pid}
<!-- udapte-end-author:sunjianlei date:20220615 for: 【issues/3709】自定义树查询条件没有处理父ID,没有树状结构了 --> </when>
<choose> <otherwise>
<when test="pid != null and pid != ''"> (${pidField} = '' OR ${pidField} IS NULL)
and ${pidField} = #{pid} </otherwise>
</when> </choose>
<otherwise> </if>
and (${pidField} = '' OR ${pidField} IS NULL) <if test="query!= null">
</otherwise> 1 = 1
</choose> <foreach collection="query.entrySet()" item="value" index="key">
<!-- udapte-end-author:sunjianlei date:20220615 for: 【issues/3709】自定义树查询条件没有处理父ID,没有树状结构了 --> <choose>
</if> <when test="key == 'tenant_id'">
<!-- udapte-end-author:sunjianlei date:20220110 for: 【JTC-597】自定义树查询条件查不出数据 --> and tenant_id = #{value}
</select> </when>
<otherwise>
and ${key} LIKE #{value}
<!-- 分页查询字典表数据 --> </otherwise>
<select id="queryDictTablePageList" parameterType="Object" resultType="org.jeecg.common.system.vo.DictModel"> </choose>
select ${query.text} as "text",${query.code} as "value" from ${query.table} </foreach>
where 1 = 1 <!-- udapte-end-author:sunjianlei date:20220615 for: 【issues/3709】自定义树查询条件没有处理父ID,没有树状结构了 -->
<if test="query.keyword != null and query.keyword != ''"> <choose>
<bind name="bindKeyword" value="'%'+query.keyword+'%'"/> <when test="pid != null and pid != ''">
and (${query.text} like #{bindKeyword} or ${query.code} like #{bindKeyword}) and ${pidField} = #{pid}
</if> </when>
<if test="query.codeValue != null and query.codeValue != ''"> <otherwise>
and ${query.code} = #{query.codeValue} and (${pidField} = '' OR ${pidField} IS NULL)
</if> </otherwise>
</select> </choose>
<!-- udapte-end-author:sunjianlei date:20220615 for: 【issues/3709】自定义树查询条件没有处理父ID,没有树状结构了 -->
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 分页--> </if>
<select id="queryTableDictWithFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <!-- udapte-end-author:sunjianlei date:20220110 for: 【JTC-597】自定义树查询条件查不出数据 -->
select ${text} as "text", ${code} as "value" from ${table} </select>
<if test="filterSql != null and filterSql != ''">
${filterSql}
</if> <!-- 分页查询字典表数据 -->
</select> <select id="queryDictTablePageList" parameterType="Object" resultType="org.jeecg.common.system.vo.DictModel">
select ${query.text} as "text",${query.code} as "value" from ${query.table}
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 获取所有 --> where 1 = 1
<select id="queryAllTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <if test="query.keyword != null and query.keyword != ''">
select ${text} as "text", ${code} as "value" from ${table} <bind name="bindKeyword" value="'%'+query.keyword+'%'"/>
<if test="filterSql != null and filterSql != ''"> and (${query.text} like #{bindKeyword} or ${query.code} like #{bindKeyword})
${filterSql} </if>
</if> <if test="query.codeValue != null and query.codeValue != ''">
</select> and ${query.code} = #{query.codeValue}
</if>
</select>
<!-- 查询字典表的数据 支持设置过滤条件、设置存储值作为in查询条件 -->
<select id="queryTableDictByKeysAndFilterSql" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel"> <!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 分页-->
select ${text} as "text", ${code} as "value" from ${table} where ${code} IN ( <select id="queryTableDictWithFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
<foreach item="key" collection="codeValues" separator=","> select ${text} as "text", ${code} as "value" from ${table}
#{key} <if test="filterSql != null and filterSql != ''">
</foreach> ${filterSql}
) </if>
<if test="filterSql != null and filterSql != ''"> </select>
and ${filterSql}
</if> <!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 获取所有 -->
</select> <select id="queryAllTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text", ${code} as "value" from ${table}
<!--根据应用id获取字典列表和详情--> <if test="filterSql != null and filterSql != ''">
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict"> ${filterSql}
select id,dict_name,dict_code from sys_dict </if>
where </select>
del_flag = 0
and low_app_id = #{lowAppId}
and tenant_id = #{tenantId} <!-- 查询字典表的数据 支持设置过滤条件、设置存储值作为in查询条件 -->
</select> <select id="queryTableDictByKeysAndFilterSql" parameterType="String"
resultType="org.jeecg.common.system.vo.DictModel">
select ${text} as "text", ${code} as "value" from ${table} where ${code} IN (
<foreach item="key" collection="codeValues" separator=",">
#{key}
</foreach>
)
<if test="filterSql != null and filterSql != ''">
and ${filterSql}
</if>
</select>
<!--根据应用id获取字典列表和详情-->
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
select id, dict_name, dict_code
from sys_dict
where del_flag = 0
and low_app_id = #{lowAppId}
and tenant_id = #{tenantId}
</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