修改一键数据处理接口
This commit is contained in:
parent
bb4abc24e1
commit
70a95f0813
@ -1,15 +1,14 @@
|
|||||||
package club.joylink.rtss.controller;
|
package club.joylink.rtss.controller;
|
||||||
|
|
||||||
|
import club.joylink.rtss.constants.Project;
|
||||||
import club.joylink.rtss.controller.org.OrgProjectController;
|
import club.joylink.rtss.controller.org.OrgProjectController;
|
||||||
import club.joylink.rtss.controller.paper.PaperCompositionController;
|
import club.joylink.rtss.controller.paper.PaperCompositionController;
|
||||||
import club.joylink.rtss.controller.publish.MapFunctionController;
|
import club.joylink.rtss.controller.publish.MapFunctionController;
|
||||||
import club.joylink.rtss.controller.user.UserController;
|
import club.joylink.rtss.controller.user.UserController;
|
||||||
import club.joylink.rtss.dao.MapDataDAO;
|
import club.joylink.rtss.dao.MapDataDAO;
|
||||||
import club.joylink.rtss.dao.MapInfoDAO;
|
import club.joylink.rtss.dao.MapInfoDAO;
|
||||||
import club.joylink.rtss.entity.MapData;
|
import club.joylink.rtss.dao.OrgDAO;
|
||||||
import club.joylink.rtss.entity.MapDataExample;
|
import club.joylink.rtss.entity.*;
|
||||||
import club.joylink.rtss.entity.MapInfo;
|
|
||||||
import club.joylink.rtss.entity.MapInfoExample;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,12 +41,16 @@ public class DataHandleController {
|
|||||||
private PaperCompositionController paperCompositionController;
|
private PaperCompositionController paperCompositionController;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserController userController;
|
private UserController userController;
|
||||||
|
@Autowired
|
||||||
|
private OrgDAO orgDAO;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public List<String> handle(HttpServletResponse response) {
|
public List<String> handle(HttpServletResponse response) {
|
||||||
correctMapVersion();
|
correctMapVersion();
|
||||||
|
|
||||||
|
confirmDefaultOrgExist();
|
||||||
|
|
||||||
orgProjectController.oldDataHandle();
|
orgProjectController.oldDataHandle();
|
||||||
|
|
||||||
List<String> msgList = new ArrayList<>(mapFunctionController.oldDataHandle());
|
List<String> msgList = new ArrayList<>(mapFunctionController.oldDataHandle());
|
||||||
@ -80,4 +84,16 @@ public class DataHandleController {
|
|||||||
mapInfoDAO.updateByPrimaryKey(mapInfo);
|
mapInfoDAO.updateByPrimaryKey(mapInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void confirmDefaultOrgExist() {
|
||||||
|
Org org = new Org();
|
||||||
|
org.setName("默认组织");
|
||||||
|
org.setProjectCode(Project.DEFAULT.name());
|
||||||
|
org.setStatus("1");
|
||||||
|
org.setCreateTime(LocalDateTime.now());
|
||||||
|
org.setCreatorId(1L);
|
||||||
|
orgDAO.insert(org);
|
||||||
|
org.setRootId(org.getId());
|
||||||
|
orgDAO.updateByPrimaryKey(org);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,30 @@
|
|||||||
package club.joylink.rtss.controller.org;
|
package club.joylink.rtss.controller.org;
|
||||||
|
|
||||||
|
import club.joylink.rtss.constants.Project;
|
||||||
import club.joylink.rtss.dao.OrgDAO;
|
import club.joylink.rtss.dao.OrgDAO;
|
||||||
import club.joylink.rtss.dao.OrgProjectDAO;
|
import club.joylink.rtss.dao.OrgProjectDAO;
|
||||||
|
import club.joylink.rtss.dao.project.ProjectDAO;
|
||||||
import club.joylink.rtss.entity.Org;
|
import club.joylink.rtss.entity.Org;
|
||||||
import club.joylink.rtss.entity.OrgExample;
|
import club.joylink.rtss.entity.OrgExample;
|
||||||
import club.joylink.rtss.entity.OrgProject;
|
import club.joylink.rtss.entity.OrgProject;
|
||||||
import club.joylink.rtss.services.org.IOrgProjectService;
|
import club.joylink.rtss.services.org.IOrgProjectService;
|
||||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织-项目关系管理接口
|
* 组织-项目关系管理接口
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/orgProject")
|
@RequestMapping("/api/orgProject")
|
||||||
public class OrgProjectController {
|
public class OrgProjectController {
|
||||||
@ -46,6 +52,8 @@ public class OrgProjectController {
|
|||||||
private OrgProjectDAO orgProjectDAO;
|
private OrgProjectDAO orgProjectDAO;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrgDAO orgDAO;
|
private OrgDAO orgDAO;
|
||||||
|
@Autowired
|
||||||
|
ProjectDAO projectDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 旧数据处理(用完删除)
|
* 旧数据处理(用完删除)
|
||||||
@ -55,22 +63,34 @@ public class OrgProjectController {
|
|||||||
public void oldDataHandle() {
|
public void oldDataHandle() {
|
||||||
orgProjectDAO.deleteByExample(null);
|
orgProjectDAO.deleteByExample(null);
|
||||||
|
|
||||||
|
//查询项目和组织数据
|
||||||
|
Map<String, club.joylink.rtss.entity.project.Project> projectMap = projectDAO.selectByExample(null).stream()
|
||||||
|
.collect(Collectors.toMap(club.joylink.rtss.entity.project.Project::getCode, Function.identity()));
|
||||||
|
OrgExample orgExample = new OrgExample();
|
||||||
|
orgExample.clear();
|
||||||
|
orgExample.createCriteria().andStatusEqualTo("1").andParentIdIsNull();
|
||||||
|
Map<String, Org> orgMap = orgDAO.selectByExample(orgExample).stream()
|
||||||
|
.collect(Collectors.toMap(Org::getProjectCode, Function.identity()));
|
||||||
|
|
||||||
OrgProject orgProject = new OrgProject();
|
OrgProject orgProject = new OrgProject();
|
||||||
orgProject.setCreateTime(LocalDateTime.now());
|
orgProject.setCreateTime(LocalDateTime.now());
|
||||||
orgProject.setCreatorId(1L);
|
orgProject.setCreatorId(1L);
|
||||||
OrgExample orgExample = new OrgExample();
|
for (Map.Entry<String, club.joylink.rtss.entity.project.Project> entry : projectMap.entrySet()) {
|
||||||
orgExample.createCriteria().andStatusEqualTo("1").andParentIdIsNull();
|
String projectCode = entry.getKey();
|
||||||
List<Org> orgs = orgDAO.selectByExample(orgExample);
|
club.joylink.rtss.entity.project.Project project = entry.getValue();
|
||||||
for (Org org : orgs) {
|
//建立项目-组织关系
|
||||||
String projectCodeStr = org.getProjectCode();
|
Org org = orgMap.get(projectCode);
|
||||||
if (StringUtils.hasText(projectCodeStr)) {
|
if (org == null) {
|
||||||
for (String projectCode : projectCodeStr.split(",")) {
|
org = orgMap.get(Project.DEFAULT.name());
|
||||||
|
}
|
||||||
orgProject.setId(null);
|
orgProject.setId(null);
|
||||||
orgProject.setOrgId(org.getId());
|
|
||||||
orgProject.setProjectCode(projectCode);
|
orgProject.setProjectCode(projectCode);
|
||||||
|
orgProject.setOrgId(org.getId());
|
||||||
|
log.info(orgProject.getOrgId() + "-" + orgProject.getProjectCode());
|
||||||
orgProjectDAO.insert(orgProject);
|
orgProjectDAO.insert(orgProject);
|
||||||
}
|
//修改项目默认组织
|
||||||
}
|
project.setDefaultOrg(org.getId());
|
||||||
|
projectDAO.updateByPrimaryKey(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user