Commit 103afbf4 authored by wzp's avatar wzp

修改bug

parent d71c1172
...@@ -119,7 +119,7 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme ...@@ -119,7 +119,7 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
public TOrgan selectById(String id) { public TOrgan selectById(String id) {
TOrgan organ = organMapper.getById(id); TOrgan organ = organMapper.getById(id);
String s = areaMapper.selectParent(organ.getAreaId()); String s = areaMapper.selectParent(organ.getAreaId());
List<TOrgan> list1 = list(new UpdateWrapper<TOrgan>().eq("parent_id", organ.getId())); List<TOrgan> list1 = list(new UpdateWrapper<TOrgan>().eq("parent_id", organ.getId()).eq("is_deleted",false));
organ.setAreas(Arrays.asList(s.split(","))); organ.setAreas(Arrays.asList(s.split(",")));
organ.setChildren(list1); organ.setChildren(list1);
return organ; return organ;
......
...@@ -69,7 +69,7 @@ public class TOrganController extends BaseController { ...@@ -69,7 +69,7 @@ public class TOrganController extends BaseController {
@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<>();
...@@ -78,7 +78,7 @@ public class TOrganController extends BaseController { ...@@ -78,7 +78,7 @@ public class TOrganController extends BaseController {
ew.eq("is_deleted", 0); ew.eq("is_deleted", 0);
ew.eq("name", organ.getName()); ew.eq("name", organ.getName());
List<TOrgan> list = this.tOrganService.list(ew); List<TOrgan> list = this.tOrganService.list(ew);
if (list != null&&list.size()>0&&list.get(0)!=null) { if (list != null && list.size() > 0 && list.get(0) != null) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("resultCode", "500"); resultMap.put("resultCode", "500");
resultMap.put("message", "机构名称不能重复!"); resultMap.put("message", "机构名称不能重复!");
...@@ -88,7 +88,13 @@ public class TOrganController extends BaseController { ...@@ -88,7 +88,13 @@ public class TOrganController extends BaseController {
organ.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); organ.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
organ.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); organ.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
String organCode = getOrganCode(organ.getParentId()); String organCode = getOrganCode(organ.getParentId());
organ.setLevel(organCode.length()/3); organ.setLevel(organCode.length() / 3);
if (organ.getLevel() > 3) {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("resultCode", "500");
resultMap.put("message", "不能添加4级机构!");
return resultMap;
}
organ.setCode(organCode); organ.setCode(organCode);
// 保存业务节点信息 // 保存业务节点信息
boolean result = tOrganService.save(organ); boolean result = tOrganService.save(organ);
...@@ -104,23 +110,29 @@ public class TOrganController extends BaseController { ...@@ -104,23 +110,29 @@ public class TOrganController extends BaseController {
@PutMapping("/update") @PutMapping("/update")
@RequiresAuthentication //@RequiresPermissions("/organ/update") @RequiresAuthentication //@RequiresPermissions("/organ/update")
@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 (!byId.getParentId().equals(tOrgan.getParentId())){ if (!byId.getParentId().equals(tOrgan.getParentId())) {
tOrgan.setCode(getOrganCode(tOrgan.getParentId())); tOrgan.setCode(getOrganCode(tOrgan.getParentId()));
} }
if (byId.getLevel()!=tOrgan.getCode().length()/3&&byId.getChildren().size()>0){ if (byId.getLevel() != tOrgan.getCode().length() / 3 && byId.getChildren().size() > 0) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("resultCode", "500"); map.put("resultCode", "500");
map.put("message", "机构存在下级机构,不能修改机构级别!"); map.put("message", "机构存在下级机构,不能修改机构级别!");
map.put("data", ""); map.put("data", "");
return map; return map;
} }
tOrgan.setLevel(tOrgan.getCode().length() / 3);
tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
if (tOrgan.getLevel() > 3) {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("resultCode", "500");
resultMap.put("message", "不能修改机构为4级!");
return resultMap;
}
boolean flag = false; boolean flag = false;
flag = tOrganService.updateById(tOrgan); flag = tOrganService.updateById(tOrgan);
if (!flag) { if (!flag) {
...@@ -141,7 +153,7 @@ public class TOrganController extends BaseController { ...@@ -141,7 +153,7 @@ public class TOrganController extends BaseController {
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "query", dataType = "String") @ApiImplicitParam(name = "id", value = "标识ID", paramType = "query", dataType = "String")
}) })
@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 = false;
try { try {
...@@ -162,7 +174,7 @@ public class TOrganController extends BaseController { ...@@ -162,7 +174,7 @@ public class TOrganController extends BaseController {
@GetMapping("/getList") @GetMapping("/getList")
@RequiresAuthentication //@RequiresPermissions("/organ/getList") @RequiresAuthentication //@RequiresPermissions("/organ/getList")
@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 = null;
try { try {
...@@ -180,7 +192,6 @@ public class TOrganController extends BaseController { ...@@ -180,7 +192,6 @@ public class TOrganController extends BaseController {
} }
@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"),
...@@ -191,7 +202,7 @@ public class TOrganController extends BaseController { ...@@ -191,7 +202,7 @@ public class TOrganController extends BaseController {
@PostMapping("/getPageList") @PostMapping("/getPageList")
@RequiresAuthentication //@RequiresPermissions("/organ/getPageList") @RequiresAuthentication //@RequiresPermissions("/organ/getPageList")
@ApiOperation(value = "获取机构分页列表", notes = "获取机构分页列表") @ApiOperation(value = "获取机构分页列表", notes = "获取机构分页列表")
@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 = null;
...@@ -207,8 +218,8 @@ public class TOrganController extends BaseController { ...@@ -207,8 +218,8 @@ public class TOrganController extends BaseController {
.le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59)); .le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
} }
//设置用户数据权限 //设置用户数据权限
queryWrapper.likeRight(TOrgan::getCode,user.getOrgCode()); queryWrapper.likeRight(TOrgan::getCode, user.getOrgCode());
queryWrapper.eq(TOrgan::getIsDeleted,false); queryWrapper.eq(TOrgan::getIsDeleted, false);
// 设置排序规则 // 设置排序规则
queryWrapper.orderByDesc(TOrgan::getCreateTime); queryWrapper.orderByDesc(TOrgan::getCreateTime);
page = this.tOrganService.page(getPage(), queryWrapper); page = this.tOrganService.page(getPage(), queryWrapper);
...@@ -222,7 +233,7 @@ public class TOrganController extends BaseController { ...@@ -222,7 +233,7 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取机构详情", notes = "获取机构详情") @ApiOperation(value = "获取机构详情", notes = "获取机构详情")
@GetMapping("/getById") @GetMapping("/getById")
@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 = null;
try { try {
...@@ -235,18 +246,18 @@ public class TOrganController extends BaseController { ...@@ -235,18 +246,18 @@ public class TOrganController extends BaseController {
} }
@GetMapping("/getTree") @GetMapping("/getTree")
@RequiresAuthentication //@RequiresPermissions("/organ/getTree") @RequiresAuthentication //@RequiresPermissions("/organ/getTree")
@ApiOperation(value = "获取机构树", notes = "获取机构树") @ApiOperation(value = "获取机构树", notes = "获取机构树")
@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 = new ArrayList<>();
try { try {
if (StringUtils.isBlank(name)) { if (StringUtils.isBlank(name)) {
list = tOrganService.getTree(user.getOrgCode()); list = tOrganService.getTree(user.getOrgCode());
}else { } else {
list = tOrganService.list(new UpdateWrapper<TOrgan>().like("name",name).likeRight("code",user.getOrgCode())); list = tOrganService.list(new UpdateWrapper<TOrgan>().like("name", name).likeRight("code", user.getOrgCode()));
} }
return getResult(list); return getResult(list);
} catch (Exception e) { } catch (Exception e) {
...@@ -258,7 +269,7 @@ public class TOrganController extends BaseController { ...@@ -258,7 +269,7 @@ public class TOrganController extends BaseController {
@GetMapping("/getAreaTree") @GetMapping("/getAreaTree")
@RequiresAuthentication //@RequiresPermissions("/organ/getAreaTree") @RequiresAuthentication //@RequiresPermissions("/organ/getAreaTree")
@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 = null;
try { try {
...@@ -275,7 +286,7 @@ public class TOrganController extends BaseController { ...@@ -275,7 +286,7 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "导入EXCEL", notes = "导入EXCEL", httpMethod = "POST") @ApiOperation(value = "导入EXCEL", notes = "导入EXCEL", httpMethod = "POST")
@RequestMapping(value = "/import", method = RequestMethod.POST) @RequestMapping(value = "/import", method = RequestMethod.POST)
@RequiresAuthentication //@RequiresPermissions("/organ/import") @RequiresAuthentication //@RequiresPermissions("/organ/import")
@MethodLog(operModule = OperModule.ORG,operType = OperType.IMPORT) @MethodLog(operModule = OperModule.ORG, operType = OperType.IMPORT)
public ResponseEntity<Map> upload(MultipartFile file) { public ResponseEntity<Map> upload(MultipartFile file) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try { try {
...@@ -284,36 +295,40 @@ public class TOrganController extends BaseController { ...@@ -284,36 +295,40 @@ public class TOrganController extends BaseController {
List excelList = ImportExcelUtil.readExcel(file.getOriginalFilename(), file.getInputStream()); List 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");
resultMap.put("massage","导入失败!"); resultMap.put("massage", "导入失败!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} }
resultMap.put("resultCode","200"); resultMap.put("resultCode", "200");
resultMap.put("massage","导入成功!"); resultMap.put("massage", "导入成功!");
return ResponseEntity.ok(resultMap); return ResponseEntity.ok(resultMap);
} catch (Exception e) { } catch (Exception e) {
resultMap.put("resultCode","500"); resultMap.put("resultCode", "500");
resultMap.put("massage",e); resultMap.put("massage", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
} }
} }
private String getOrganCode(String parentId) { private String getOrganCode(String parentId) {
TOrgan max = tOrganService.selectCodeMax(parentId); TOrgan max = tOrganService.selectCodeMax(parentId);
if (max==null){ TOrgan byId = tOrganService.getById(parentId);
max = tOrganService.getById(parentId); if (max == null) {
String s = max.getCode() + "001"; if (byId != null) {
return s; String s = byId.getCode() + "001";
return s;
}else {
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; Integer integer = Integer.valueOf(s) + 1;
if (integer<10){ if (integer < 10) {
s1=s1+"00"+integer.toString(); s1 = s1 + "00" + integer.toString();
}else if (integer<100){ } else if (integer < 100) {
s1=s1+"0"+integer.toString(); s1 = s1 + "0" + integer.toString();
}else { } else {
s1=s1+integer.toString(); s1 = s1 + integer.toString();
} }
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