Commit 94969947 authored by liqin's avatar liqin 💬

bug fixed

parent be7b3d9b
...@@ -5,10 +5,7 @@ import org.apache.poi.ss.usermodel.*; ...@@ -5,10 +5,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ImportExcelUtil { public class ImportExcelUtil {
...@@ -44,8 +41,7 @@ public class ImportExcelUtil { ...@@ -44,8 +41,7 @@ public class ImportExcelUtil {
List<Map<String, String>> list = new ArrayList<>(); List<Map<String, String>> list = new ArrayList<>();
for (int i = 1; i <= lastRowNum; i++) { for (int i = 1; i <= lastRowNum; i++) {
ArrayList<String> list1 = new ArrayList<>(); HashMap<String, String> map = new LinkedHashMap<>();
HashMap<String, String> map = new HashMap<>();
//获取行数据 //获取行数据
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
for (int j = 0; j < lastCellNum; j++) { for (int j = 0; j < lastCellNum; j++) {
...@@ -53,8 +49,7 @@ public class ImportExcelUtil { ...@@ -53,8 +49,7 @@ public class ImportExcelUtil {
Cell cell = row.getCell(j); Cell cell = row.getCell(j);
if (cell != null) { if (cell != null) {
cell.setCellType(CellType.STRING); cell.setCellType(CellType.STRING);
//获取单元格数据 //cell.setCellFormula(CellType.STRING.name());
list1.add(cell.getStringCellValue());
//列名 :数据 //列名 :数据
map.put(titleRow.getCell(j).getStringCellValue(), cell.getStringCellValue()); map.put(titleRow.getCell(j).getStringCellValue(), cell.getStringCellValue());
} }
......
...@@ -21,14 +21,13 @@ public class MybatisPlusConfig { ...@@ -21,14 +21,13 @@ public class MybatisPlusConfig {
* mybatis-plus乐观锁插件 * mybatis-plus乐观锁插件
*/ */
@Bean @Bean
public OptimisticLockerInnerInterceptor optimisticLockerInterceptor() { public OptimisticLockerInnerInterceptor optimisticLockerInterceptor() { return new OptimisticLockerInnerInterceptor(); }
return new OptimisticLockerInnerInterceptor();
}
/**
* 攻击SQL阻断解析器,防止全表更新与删除
*/
@Bean @Bean
public BlockAttackInnerInterceptor blockAttackInnerInterceptor() { public BlockAttackInnerInterceptor blockAttackInnerInterceptor() { return new BlockAttackInnerInterceptor(); }
return new BlockAttackInnerInterceptor();
}
/** /**
* 自定义 SqlInjector * 自定义 SqlInjector
......
...@@ -49,13 +49,11 @@ public class TOrganController extends BaseController { ...@@ -49,13 +49,11 @@ public class TOrganController extends BaseController {
@Resource @Resource
private TAreaService tAreaService; private TAreaService tAreaService;
@PostMapping("/add") @PostMapping("/add")
@RequiresAuthentication //@RequiresPermissions("/organ/add") @RequiresAuthentication //@RequiresPermissions("/organ/add")
@ApiOperation(value = "添加机构", notes = "添加机构") @ApiOperation(value = "添加机构", notes = "添加机构")
@MethodLog(operModule = OperModule.ORG, operType = OperType.ADD) @MethodLog(operModule = OperModule.ORG, operType = OperType.ADD)
public Map<String, Object> add(TOrgan organ) { public Map<String, Object> add(TOrgan organ) {
QueryWrapper<TOrgan> ew = new QueryWrapper<>(); QueryWrapper<TOrgan> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(organ.getName())) { if (StringUtils.isNoneBlank(organ.getName())) {
organ.setName(organ.getName().trim()); organ.setName(organ.getName().trim());
...@@ -96,7 +94,6 @@ public class TOrganController extends BaseController { ...@@ -96,7 +94,6 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "update", notes = "修改机构信息") @ApiOperation(value = "update", notes = "修改机构信息")
@MethodLog(operModule = OperModule.ORG, operType = OperType.UPDATE) @MethodLog(operModule = OperModule.ORG, operType = OperType.UPDATE)
public Map<String, Object> updateTOrgan(TOrgan tOrgan) { public Map<String, Object> updateTOrgan(TOrgan tOrgan) {
try { try {
TOrgan byId = tOrganService.selectById(tOrgan.getId()); TOrgan byId = tOrganService.selectById(tOrgan.getId());
if (StringUtils.isNotBlank(tOrgan.getParentId())) { if (StringUtils.isNotBlank(tOrgan.getParentId())) {
...@@ -121,7 +118,7 @@ public class TOrganController extends BaseController { ...@@ -121,7 +118,7 @@ public class TOrganController extends BaseController {
} }
} }
tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
boolean flag = false; boolean flag;
flag = tOrganService.updateById(tOrgan); flag = tOrganService.updateById(tOrgan);
if (!flag) { if (!flag) {
return getFailResult(); return getFailResult();
...@@ -134,7 +131,6 @@ public class TOrganController extends BaseController { ...@@ -134,7 +131,6 @@ public class TOrganController extends BaseController {
return getFailResult(); return getFailResult();
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")
@RequiresAuthentication //@RequiresPermissions("/organ/delete") @RequiresAuthentication //@RequiresPermissions("/organ/delete")
@ApiOperation(value = "根据ID删除机构", notes = "根据ID删除机构") @ApiOperation(value = "根据ID删除机构", notes = "根据ID删除机构")
...@@ -143,7 +139,7 @@ public class TOrganController extends BaseController { ...@@ -143,7 +139,7 @@ public class TOrganController extends BaseController {
}) })
@MethodLog(operModule = OperModule.ORG, operType = OperType.DELETE) @MethodLog(operModule = OperModule.ORG, operType = OperType.DELETE)
public Map<String, Object> deleteTOrgan(String id) { public Map<String, Object> deleteTOrgan(String id) {
boolean result = false; boolean result;
try { try {
TOrgan tOrgan = tOrganService.getById(id); TOrgan tOrgan = tOrganService.getById(id);
tOrgan.setIsDeleted(true); tOrgan.setIsDeleted(true);
...@@ -164,11 +160,11 @@ public class TOrganController extends BaseController { ...@@ -164,11 +160,11 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)") @ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)")
@MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT)
public Map<String, Object> getTOrganList() { public Map<String, Object> getTOrganList() {
TUser user = null; TUser user;
try { try {
user = getcurUser(); user = getcurUser();
TOrgan tOrgan = new TOrgan(); TOrgan tOrgan = new TOrgan();
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) { if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
//设置用户数据权限 //设置用户数据权限
tOrgan.setCode(user.getOrgCode()); tOrgan.setCode(user.getOrgCode());
} }
...@@ -178,10 +174,8 @@ public class TOrganController extends BaseController { ...@@ -178,10 +174,8 @@ public class TOrganController extends BaseController {
e.printStackTrace(); e.printStackTrace();
} }
return getFailResult(); return getFailResult();
} }
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
...@@ -195,7 +189,7 @@ public class TOrganController extends BaseController { ...@@ -195,7 +189,7 @@ public class TOrganController extends BaseController {
@MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT)
public Map<String, Object> getTOrganPageList(GenericPageParam genericPageParam) { public Map<String, Object> getTOrganPageList(GenericPageParam genericPageParam) {
TUser user = getcurUser(); TUser user = getcurUser();
Page<TOrgan> page = null; Page<TOrgan> page;
try { try {
LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>();
// 对名称或编码模糊查询 // 对名称或编码模糊查询
...@@ -207,7 +201,7 @@ public class TOrganController extends BaseController { ...@@ -207,7 +201,7 @@ public class TOrganController extends BaseController {
queryWrapper.ge(TOrgan::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0)) queryWrapper.ge(TOrgan::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
.le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59)); .le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
} }
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) { if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
//设置用户数据权限 //设置用户数据权限
queryWrapper.likeRight(TOrgan::getCode, user.getOrgCode()); queryWrapper.likeRight(TOrgan::getCode, user.getOrgCode());
} }
...@@ -227,7 +221,7 @@ public class TOrganController extends BaseController { ...@@ -227,7 +221,7 @@ public class TOrganController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("/organ/getById") @RequiresAuthentication //@RequiresPermissions("/organ/getById")
@MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT)
public Map<String, Object> getById(String id) { public Map<String, Object> getById(String id) {
TOrgan tOrgan = null; TOrgan tOrgan;
try { try {
tOrgan = tOrganService.selectById(id); tOrgan = tOrganService.selectById(id);
return getResult(tOrgan); return getResult(tOrgan);
...@@ -244,13 +238,13 @@ public class TOrganController extends BaseController { ...@@ -244,13 +238,13 @@ public class TOrganController extends BaseController {
@MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT)
public Map<String, Object> getTree(String name) { public Map<String, Object> getTree(String name) {
TUser user = getcurUser(); TUser user = getcurUser();
List<TOrgan> list = new ArrayList<>(); List<TOrgan> list;
UpdateWrapper<TOrgan> wrapper = new UpdateWrapper<>(); UpdateWrapper<TOrgan> wrapper = new UpdateWrapper<>();
try { try {
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) { if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
//设置用户数据权限 //设置用户数据权限
wrapper.likeRight("code", user.getOrgCode()); wrapper.likeRight("code", user.getOrgCode());
}else { } else {
user.setOrgCode(""); user.setOrgCode("");
} }
if (StringUtils.isBlank(name)) { if (StringUtils.isBlank(name)) {
...@@ -271,7 +265,7 @@ public class TOrganController extends BaseController { ...@@ -271,7 +265,7 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取区域树", notes = "获取区域树") @ApiOperation(value = "获取区域树", notes = "获取区域树")
@MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG, operType = OperType.SELECT)
public Map<String, Object> getAreaTree() { public Map<String, Object> getAreaTree() {
List<TArea> list = null; List<TArea> list;
try { try {
list = tAreaService.getAreaTree(); list = tAreaService.getAreaTree();
return getResult(list); return getResult(list);
...@@ -288,11 +282,11 @@ public class TOrganController extends BaseController { ...@@ -288,11 +282,11 @@ public class TOrganController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("/organ/import") @RequiresAuthentication //@RequiresPermissions("/organ/import")
@MethodLog(operModule = OperModule.ORG, operType = OperType.IMPORT) @MethodLog(operModule = OperModule.ORG, operType = OperType.IMPORT)
public Map<String, Object> upload(MultipartFile file) { public Map<String, Object> upload(MultipartFile file) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); Map<String, Object> resultMap = new LinkedHashMap<>();
try { try {
boolean flag = false; boolean flag;
//使用工具类从文件中读取数据 //使用工具类从文件中读取数据
List excelList = ImportExcelUtil.readExcel(file.getOriginalFilename(), file.getInputStream()); final List<Map<String, String>> excelList = ImportExcelUtil.readExcel(file.getOriginalFilename(), file.getInputStream());
flag = tOrganService.batchUpload(excelList); flag = tOrganService.batchUpload(excelList);
if (!flag) { if (!flag) {
resultMap.put("resultCode", "500"); resultMap.put("resultCode", "500");
...@@ -314,21 +308,20 @@ public class TOrganController extends BaseController { ...@@ -314,21 +308,20 @@ public class TOrganController extends BaseController {
TOrgan byId = tOrganService.getById(parentId); TOrgan byId = tOrganService.getById(parentId);
if (max == null) { if (max == null) {
if (byId != null) { if (byId != null) {
String s = byId.getCode() + "001"; return byId.getCode() + "001";
return s; } else {
}else {
return "001"; return "001";
} }
} }
String s = max.getCode().substring(max.getCode().length() - 3); String s = max.getCode().substring(max.getCode().length() - 3);
String s1 = max.getCode().substring(0, max.getCode().length() - 3); String s1 = max.getCode().substring(0, max.getCode().length() - 3);
Integer integer = Integer.valueOf(s) + 1; int integer = Integer.parseInt(s) + 1;
if (integer < 10) { if (integer < 10) {
s1 = s1 + "00" + integer.toString(); s1 = s1 + "00" + integer;
} else if (integer < 100) { } else if (integer < 100) {
s1 = s1 + "0" + integer.toString(); s1 = s1 + "0" + integer;
} else { } else {
s1 = s1 + integer.toString(); s1 = s1 + integer;
} }
return s1; return s1;
} }
......
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