|
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.persagy.common.criteria.CriteriaUtils;
|
|
|
import com.persagy.common.criteria.JacksonCriteria;
|
|
|
-import com.persagy.common.web.BaseResponse;
|
|
|
import com.persagy.common.web.MapResponse;
|
|
|
import com.persagy.common.web.PagedResponse;
|
|
|
import com.persagy.dmp.config.DmpParameterStorage;
|
|
@@ -21,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
-import javax.validation.Valid;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -105,7 +103,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
return response;
|
|
|
}
|
|
|
if (orgParam != null) {
|
|
|
- if (params == null || params.isEmpty()){
|
|
|
+ if (params == null || params.isEmpty()) {
|
|
|
response.setFail("传入数据为空!");
|
|
|
return response;
|
|
|
}
|
|
@@ -115,7 +113,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
List<CompanyProjectRel> companyProjectRels = new ArrayList<>();
|
|
|
for (CompanyModel param : params) {
|
|
|
Company entity = Company.fromModel(param);
|
|
|
- if (entity.getCode() == null || entity.getCode().isEmpty()){
|
|
|
+ if (entity.getCode() == null || entity.getCode().isEmpty()) {
|
|
|
response.setFail("公司 code 不可为空!");
|
|
|
return response;
|
|
|
}
|
|
@@ -127,7 +125,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
response.setFail("公司 code 不能重复!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
|
- if (entity.getName() == null || entity.getName().isEmpty()){
|
|
|
+ if (entity.getName() == null || entity.getName().isEmpty()) {
|
|
|
response.setFail("公司 name 不可为空!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
@@ -173,12 +171,12 @@ public class CompanyService extends OrgBaseService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (companies == null || companies.isEmpty()){
|
|
|
+ if (companies == null || companies.isEmpty()) {
|
|
|
response.setFail("无新建数据!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
|
companyRepository.saveAll(companies);
|
|
|
- if (companyProjectRels != null && !companyProjectRels.isEmpty()){
|
|
|
+ if (companyProjectRels != null && !companyProjectRels.isEmpty()) {
|
|
|
companyProjectRelRepository.saveAll(companyProjectRels);
|
|
|
}
|
|
|
List<String> returnValue = companies.stream().map(Company::getId).collect(Collectors.toList());
|
|
@@ -197,7 +195,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
return response;
|
|
|
}
|
|
|
if (orgParam != null) {
|
|
|
- if (params == null || params.isEmpty()){
|
|
|
+ if (params == null || params.isEmpty()) {
|
|
|
response.setFail("传入数据为空!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
@@ -219,7 +217,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
Company one = optional.get();
|
|
|
|
|
|
if (param.getCode() != null) {
|
|
|
- if (param.getCode() != one.getCode()){
|
|
|
+ if (param.getCode() != one.getCode()) {
|
|
|
|
|
|
long codeFlag = companyRepository.count(qCompany.code.eq(param.getCode())
|
|
|
.and(qCompany.groupCode.eq(orgParam.groupCode)));
|
|
@@ -231,7 +229,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
one.setCode(param.getCode());
|
|
|
}
|
|
|
if (param.getName() != null) {
|
|
|
- if (param.getName() != one.getName()){
|
|
|
+ if (param.getName() != one.getName()) {
|
|
|
|
|
|
long nameFlag = companyRepository.count(qCompany.name.eq(param.getName())
|
|
|
.and(qCompany.groupCode.eq(orgParam.groupCode)));
|
|
@@ -294,18 +292,18 @@ public class CompanyService extends OrgBaseService {
|
|
|
}
|
|
|
saves.addAll(cprs);
|
|
|
}
|
|
|
- if (companies == null || companies.isEmpty()){
|
|
|
+ if (companies == null || companies.isEmpty()) {
|
|
|
response.setFail("无可更新的数据!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
|
|
|
|
companyRepository.saveAll(companies);
|
|
|
|
|
|
- if (deletes != null && !deletes.isEmpty()){
|
|
|
+ if (deletes != null && !deletes.isEmpty()) {
|
|
|
companyProjectRelRepository.deleteAll(deletes);
|
|
|
}
|
|
|
|
|
|
- if (saves != null && !saves.isEmpty()){
|
|
|
+ if (saves != null && !saves.isEmpty()) {
|
|
|
companyProjectRelRepository.saveAll(saves);
|
|
|
}
|
|
|
List<String> returnValue = params.stream().map(CompanyModel::getId).collect(Collectors.toList());
|
|
@@ -318,6 +316,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
|
|
|
|
|
|
* TODO 确认删除公司后,部门\岗位\人员如何处理?
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
*/
|
|
@@ -330,7 +329,7 @@ public class CompanyService extends OrgBaseService {
|
|
|
return response;
|
|
|
}
|
|
|
if (orgParam != null) {
|
|
|
- if (params == null || params.isEmpty()){
|
|
|
+ if (params == null || params.isEmpty()) {
|
|
|
response.setFail("传入数据为空!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
@@ -365,12 +364,12 @@ public class CompanyService extends OrgBaseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (companies == null || companies.isEmpty()){
|
|
|
+ if (companies == null || companies.isEmpty()) {
|
|
|
response.setFail("无可删除的数据!");
|
|
|
throw new OrgCURDRunTimeException(response);
|
|
|
}
|
|
|
companyRepository.saveAll(companies);
|
|
|
- if (deletes != null && !deletes.isEmpty()){
|
|
|
+ if (deletes != null && !deletes.isEmpty()) {
|
|
|
companyProjectRelRepository.deleteAll(deletes);
|
|
|
}
|
|
|
List<String> returnValue = companies.stream().map(Company::getId).collect(Collectors.toList());
|
|
@@ -379,4 +378,30 @@ public class CompanyService extends OrgBaseService {
|
|
|
}
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public MapResponse initCompony() {
|
|
|
+ MapResponse resp = new MapResponse();
|
|
|
+ String groupCode = DmpParameterStorage.getGroupCode();
|
|
|
+ QGroup qt = QGroup.group;
|
|
|
+ Optional<Group> opt = groupRepository.findOne(qt.code.eq(groupCode));
|
|
|
+ if (opt.isPresent()) {
|
|
|
+ Group group = opt.get();
|
|
|
+ Company company = new Company();
|
|
|
+ company.setId(OrgUtils.getUUID());
|
|
|
+ company.setGroupCode(groupCode);
|
|
|
+ company.setCode(groupCode);
|
|
|
+ company.setName(group.getName());
|
|
|
+ company.setParentId("0");
|
|
|
+ company.setStatus(1);
|
|
|
+ company.setCreateUser(DmpParameterStorage.getUserId());
|
|
|
+ company.setCreateTime(new Date());
|
|
|
+ companyRepository.save(company);
|
|
|
+ } else {
|
|
|
+ resp.setFail("集团[" + groupCode + "]不存在!");
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
}
|