|
|
@@ -592,7 +592,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
public Object pushCompanyData(pushCompanyDataBo in) {
|
|
|
//导入部门
|
|
|
if (!in.getListDep().isEmpty()){
|
|
|
- pushAddDep(in.getListDep());
|
|
|
+ String kyId = pushAddDep(in.getListDep());
|
|
|
}
|
|
|
//导入用户
|
|
|
if (!in.getListUser().isEmpty()){
|
|
|
@@ -600,7 +600,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
}
|
|
|
//导入用户项目
|
|
|
if (!in.getListUserProject().isEmpty()){
|
|
|
- pushAddUserProject(in.getListUserProject());
|
|
|
+ pushAddUserProject(in.getListUserProject(),kyId);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -626,18 +626,29 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
p.setAid(sysUser.getUserId());
|
|
|
p.setName(sysUser.getNickName());
|
|
|
}
|
|
|
- p.setProjectStatus(0);
|
|
|
- p.setProcessStatus(2);
|
|
|
p.setRecordTime(DateUtils.parseDate(e.getRecordTime()));
|
|
|
p.setDuration(e.getDuration());
|
|
|
- p.setCheckStatus(0);
|
|
|
p.setInitDuration(e.getDuration());
|
|
|
- projectStaffRecordMapper.insertSelective(p);
|
|
|
+ //如果是已有数据覆盖,没有数据新增
|
|
|
+ ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPidAndAidAndTime(p.getPid(), p.getAid(), p.getRecordTime());
|
|
|
+ p.setProjectStatus(0);
|
|
|
+ p.setProcessStatus(2);
|
|
|
+ p.setCheckStatus(0);
|
|
|
+ if (projectStaffRecord!=null){
|
|
|
+ p.setId(projectStaffRecord.getId());
|
|
|
+ projectStaffRecordMapper.updateByPrimaryKeySelective(p);
|
|
|
+ }else{
|
|
|
+ projectStaffRecordMapper.insertSelective(p);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
+ //更新项目总时长
|
|
|
projectMap.values().stream().forEach(e -> {
|
|
|
projectTaskMapper.updateDuration(e.getId());
|
|
|
});
|
|
|
+ //更新用户总时长
|
|
|
userMap.values().stream().forEach(e -> {
|
|
|
userMapper.updateDuration(e.getUserId());
|
|
|
});
|
|
|
@@ -666,7 +677,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void pushAddUserProject(List<pushDataProject> listUserProject) {
|
|
|
+ private void pushAddUserProject(List<pushDataProject> listUserProject,String kyId) {
|
|
|
listUserProject.stream().forEach(e -> {
|
|
|
ProjectTask projectTask = new ProjectTask();
|
|
|
projectTask.setName(e.getProjectName());
|
|
|
@@ -686,6 +697,8 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
projectTask.setCrossYear(0);
|
|
|
projectTask.setDuration(0d);
|
|
|
projectTask.setCreateTime(new Date());
|
|
|
+ //存在则修改,不存在则新增
|
|
|
+ ProjectTask projectTask1 = projectTaskMapper.selectByProjectNumber(projectTask.getProjectNumber(), projectTask.getDeptId());
|
|
|
projectTaskMapper.insert(projectTask);
|
|
|
if (e.getStaffIds()!=null){
|
|
|
String[] split = e.getStaffIds().split(",");
|
|
|
@@ -718,23 +731,31 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
sysUser.setNickName(e.getNickName());
|
|
|
sysUser.setKyId(e.getKyId());
|
|
|
sysUser.setKySuperId(e.getKySuperId());
|
|
|
- sysUser.setPassword(SecurityUtils.encryptPassword("123456"));
|
|
|
- sysUser.setStatus("0");
|
|
|
- sysUser.setDelFlag("0");
|
|
|
if (e.getKyDeptId()!=null){
|
|
|
SysDept sysDept = sysDeptMapper.selectByKyId(e.getKyDeptId());
|
|
|
sysUser.setDeptId(sysDept.getDeptId());
|
|
|
}
|
|
|
- SysUser sysUser1 = userMapper.selectByKyId(e.getKySuperId());
|
|
|
- if (sysUser1==null){
|
|
|
- userMapper.insertUser(sysUser);
|
|
|
- notSuperList.add(sysUser);
|
|
|
+ //如果系统已经存在则修改
|
|
|
+ SysUser sysUser2 = userMapper.selectByKyId(e.getKyId());
|
|
|
+ if (sysUser2!=null){
|
|
|
+ sysUser.setUserId(sysUser2.getUserId());
|
|
|
+ userMapper.updateUser(sysUser);
|
|
|
}else {
|
|
|
- sysUser.setSuperiorId(sysUser1.getUserId());
|
|
|
- userMapper.insertUser(sysUser);
|
|
|
+ sysUser.setPassword(SecurityUtils.encryptPassword("123456"));
|
|
|
+ sysUser.setStatus("0");
|
|
|
+ sysUser.setDelFlag("0");
|
|
|
+ SysUser sysUser1 = userMapper.selectByKyId(e.getKySuperId());
|
|
|
+ if (sysUser1==null){
|
|
|
+ userMapper.insertUser(sysUser);
|
|
|
+ notSuperList.add(sysUser);
|
|
|
+ }else {
|
|
|
+ sysUser.setSuperiorId(sysUser1.getUserId());
|
|
|
+ userMapper.insertUser(sysUser);
|
|
|
+ }
|
|
|
}
|
|
|
allUserList.add(sysUser);
|
|
|
});
|
|
|
+ //处理没有找到上级的账户
|
|
|
if (!notSuperList.isEmpty()){
|
|
|
notSuperList.stream().forEach(e -> {
|
|
|
SysUser sysUser1 = userMapper.selectByKyId(e.getKySuperId());
|
|
|
@@ -766,15 +787,26 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void pushAddDep(List<pushDataDep> listDep) {
|
|
|
+ private String pushAddDep(List<pushDataDep> listDep) {
|
|
|
//假设只设置2级 1级为公司
|
|
|
List<pushDataDep> sp1 = listDep.stream().filter(e -> StringUtils.isNotEmpty(e.getUsci())).collect(Collectors.toList());
|
|
|
//先新增公司
|
|
|
pushDataDep pushDataDep = sp1.get(0);
|
|
|
SysDept sysDept1 = sysDeptMapper.selectByusci(pushDataDep.getUsci());
|
|
|
- if (sysDept1!=null) throw new ServiceException("公司已存在");
|
|
|
- SysDept sysDept=addCompany(pushDataDep);
|
|
|
- pushDep(listDep, pushDataDep.getKyId(),sysDept);
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
+ sysDept.setUsci(pushDataDep.getUsci());
|
|
|
+ sysDept.setDeptName(pushDataDep.getDeptName());
|
|
|
+ sysDept.setKyId(pushDataDep.getKyId());
|
|
|
+ sysDept.setParentId(100l);
|
|
|
+ sysDept.setAncestors("0,100");
|
|
|
+ if (sysDept1==null){
|
|
|
+ sysDeptMapper.insertDept(sysDept);
|
|
|
+ }else {
|
|
|
+ sysDept.setDeptId(sysDept1.getDeptId());
|
|
|
+ sysDeptMapper.updateDept(sysDept1);
|
|
|
+ }
|
|
|
+ pushDep(listDep, pushDataDep.getKyId(),sysDept1);
|
|
|
+ return pushDataDep.getKyId();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -793,21 +825,18 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
|
|
|
sysDept.setCompanyId(pushDataDep.getDeptId());
|
|
|
sysDept.setParentId(sysDept1.getDeptId());
|
|
|
sysDept.setAncestors(sysDept1.getAncestors()+","+sysDept1.getDeptId());
|
|
|
- sysDeptMapper.insertDept(sysDept);
|
|
|
+ //如果存在则覆盖
|
|
|
+ SysDept useDept = sysDeptMapper.selectByKyId(e.getKyId());
|
|
|
+ if (useDept!=null){
|
|
|
+ sysDept.setDeptId(useDept.getDeptId());
|
|
|
+ sysDeptMapper.updateDept(sysDept);
|
|
|
+ }else {
|
|
|
+ sysDeptMapper.insertDept(sysDept);
|
|
|
+ }
|
|
|
+
|
|
|
pushDep(listDep, e.getKyId(),pushDataDep);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private SysDept addCompany(pushDataDep pushDataDep) {
|
|
|
- SysDept sysDept = new SysDept();
|
|
|
- sysDept.setUsci(pushDataDep.getUsci());
|
|
|
- sysDept.setDeptName(pushDataDep.getDeptName());
|
|
|
- sysDept.setKyId(pushDataDep.getKyId());
|
|
|
- sysDept.setParentId(100l);
|
|
|
- sysDept.setAncestors("0,100");
|
|
|
- sysDeptMapper.insertDept(sysDept);
|
|
|
- return sysDept;
|
|
|
- }
|
|
|
-
|
|
|
}
|