|
@@ -26,12 +26,11 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.los.Util.IDeptUtils;
|
|
import org.springblade.los.Util.IDeptUtils;
|
|
|
-import org.springblade.los.excel.BCorpsExcel;
|
|
|
|
|
import org.springblade.los.basic.corps.entity.*;
|
|
import org.springblade.los.basic.corps.entity.*;
|
|
|
import org.springblade.los.basic.corps.mapper.CorpsMapper;
|
|
import org.springblade.los.basic.corps.mapper.CorpsMapper;
|
|
|
import org.springblade.los.basic.corps.service.*;
|
|
import org.springblade.los.basic.corps.service.*;
|
|
|
import org.springblade.los.basic.corps.vo.BCorpsVO;
|
|
import org.springblade.los.basic.corps.vo.BCorpsVO;
|
|
|
-import org.springblade.system.entity.Dept;
|
|
|
|
|
|
|
+import org.springblade.los.excel.BCorpsExcel;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
@@ -94,7 +93,7 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
public R submit(BCorps bCorps) {
|
|
public R submit(BCorps bCorps) {
|
|
|
String deptId = "";
|
|
String deptId = "";
|
|
|
String deptName = "";
|
|
String deptName = "";
|
|
|
- String branchId = deptUtils.getDeptPid()+"";
|
|
|
|
|
|
|
+ String branchId = deptUtils.getDeptPid() + "";
|
|
|
//获取部门ids对应中文名
|
|
//获取部门ids对应中文名
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
deptId = AuthUtil.getDeptId();
|
|
deptId = AuthUtil.getDeptId();
|
|
@@ -103,11 +102,11 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
deptName = String.join(",", res.getData());
|
|
deptName = String.join(",", res.getData());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- long cname = baseMapper.selectCount(new LambdaQueryWrapper<BCorps>()
|
|
|
|
|
|
|
+ List<BCorps> cname = baseMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getCnName, bCorps.getCnName())
|
|
.eq(BCorps::getCnName, bCorps.getCnName())
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0));
|
|
.eq(BCorps::getIsDeleted, 0));
|
|
|
- long uscc = baseMapper.selectCount(new LambdaQueryWrapper<BCorps>()
|
|
|
|
|
|
|
+ List<BCorps> uscc = baseMapper.selectList(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getUscc, bCorps.getUscc())
|
|
.eq(BCorps::getUscc, bCorps.getUscc())
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0));
|
|
.eq(BCorps::getIsDeleted, 0));
|
|
@@ -118,10 +117,10 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
bCorps.setInitials(initials.substring(0, 1));
|
|
bCorps.setInitials(initials.substring(0, 1));
|
|
|
}
|
|
}
|
|
|
if (bCorps.getId() == null) {
|
|
if (bCorps.getId() == null) {
|
|
|
- if (cname > 0) {
|
|
|
|
|
|
|
+ if (cname.size() > 0) {
|
|
|
throw new RuntimeException("中文名称不允许重复");
|
|
throw new RuntimeException("中文名称不允许重复");
|
|
|
}
|
|
}
|
|
|
- if (uscc > 0) {
|
|
|
|
|
|
|
+ if (uscc.size() > 0) {
|
|
|
throw new RuntimeException("统一社会信用代码不允许重复");
|
|
throw new RuntimeException("统一社会信用代码不允许重复");
|
|
|
}
|
|
}
|
|
|
bCorps.setCreateTime(new Date());
|
|
bCorps.setCreateTime(new Date());
|
|
@@ -129,18 +128,44 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
bCorps.setCreateUserName(AuthUtil.getUserName());
|
|
bCorps.setCreateUserName(AuthUtil.getUserName());
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
bCorps.setDeptName(AuthUtil.getUserName());
|
|
bCorps.setDeptName(AuthUtil.getUserName());
|
|
|
- bCorps.setDeptId(deptUtils.getDeptPid()+"");
|
|
|
|
|
|
|
+ bCorps.setDeptId(deptUtils.getDeptPid() + "");
|
|
|
bCorps.setBranchId(branchId);
|
|
bCorps.setBranchId(branchId);
|
|
|
bCorps.setCreateDept(deptId);
|
|
bCorps.setCreateDept(deptId);
|
|
|
bCorps.setCreateDeptName(deptName);
|
|
bCorps.setCreateDeptName(deptName);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if (cname > 1) {
|
|
|
|
|
|
|
+ List<Long> ids = cname.stream().map(BCorps::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ List<Long> ids1 = uscc.stream().map(BCorps::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ if (cname.size() > 0 && !ids.contains(bCorps.getId())) {
|
|
|
throw new RuntimeException("中文名称不允许重复");
|
|
throw new RuntimeException("中文名称不允许重复");
|
|
|
}
|
|
}
|
|
|
- if (uscc > 1) {
|
|
|
|
|
|
|
+ if (uscc.size() > 0 && !ids1.contains(bCorps.getId())) {
|
|
|
throw new RuntimeException("统一社会信用代码不允许重复");
|
|
throw new RuntimeException("统一社会信用代码不允许重复");
|
|
|
}
|
|
}
|
|
|
|
|
+ BCorps bCorps1 = baseMapper.selectById(bCorps.getId());
|
|
|
|
|
+ if (bCorps1 != null){
|
|
|
|
|
+ if (!bCorps1.getCnName().equals(bCorps.getCnName())) {
|
|
|
|
|
+ BCorpsRename item = new BCorpsRename();
|
|
|
|
|
+ item.setPid(bCorps.getId());
|
|
|
|
|
+ item.setOldCnName(bCorps1.getCnName());
|
|
|
|
|
+ item.setNewCnName(bCorps.getCnName());
|
|
|
|
|
+ item.setOldEnName(bCorps1.getEnName());
|
|
|
|
|
+ item.setNewEnName(bCorps.getEnName());
|
|
|
|
|
+ item.setById(AuthUtil.getUserId());
|
|
|
|
|
+ item.setByName(AuthUtil.getUserName());
|
|
|
|
|
+ item.setByTime(new Date());
|
|
|
|
|
+ item.setCreateTime(new Date());
|
|
|
|
|
+ item.setCreateUser(AuthUtil.getUserId());
|
|
|
|
|
+ item.setCreateUserName(AuthUtil.getUserName());
|
|
|
|
|
+ item.setByTime(new Date());
|
|
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
|
|
+ item.setBranchId(branchId);
|
|
|
|
|
+ item.setCreateDept(deptId);
|
|
|
|
|
+ item.setCreateDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+ bCorpsRenameService.save(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
bCorps.setUpdateUser(AuthUtil.getUserId());
|
|
bCorps.setUpdateUser(AuthUtil.getUserId());
|
|
|
bCorps.setUpdateTime(new Date());
|
|
bCorps.setUpdateTime(new Date());
|
|
|
bCorps.setUpdateUserName(AuthUtil.getUserName());
|
|
bCorps.setUpdateUserName(AuthUtil.getUserName());
|
|
@@ -350,7 +375,7 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
public R<List<BCorps>> importBCorps(List<BCorpsExcel> excelList) {
|
|
public R<List<BCorps>> importBCorps(List<BCorpsExcel> excelList) {
|
|
|
String deptId = "";
|
|
String deptId = "";
|
|
|
String deptName = "";
|
|
String deptName = "";
|
|
|
- String branchId = deptUtils.getDeptPid()+"";
|
|
|
|
|
|
|
+ String branchId = deptUtils.getDeptPid() + "";
|
|
|
//获取部门ids对应中文名
|
|
//获取部门ids对应中文名
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
deptId = AuthUtil.getDeptId();
|
|
deptId = AuthUtil.getDeptId();
|
|
@@ -403,7 +428,7 @@ public class BCorpsServiceImpl extends ServiceImpl<CorpsMapper, BCorps> implemen
|
|
|
bCorps.setCreateUserName(AuthUtil.getUserName());
|
|
bCorps.setCreateUserName(AuthUtil.getUserName());
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
bCorps.setDeptName(AuthUtil.getUserName());
|
|
bCorps.setDeptName(AuthUtil.getUserName());
|
|
|
- bCorps.setDeptId(deptUtils.getDeptPid()+"");
|
|
|
|
|
|
|
+ bCorps.setDeptId(deptUtils.getDeptPid() + "");
|
|
|
bCorps.setCreateDept(deptId);
|
|
bCorps.setCreateDept(deptId);
|
|
|
bCorps.setBranchId(branchId);
|
|
bCorps.setBranchId(branchId);
|
|
|
bCorps.setCreateDeptName(deptName);
|
|
bCorps.setCreateDeptName(deptName);
|