|
|
@@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import com.jzg.commons.annotation.IgnoreTenant;
|
|
|
import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
+import com.jzg.commons.entity.po.EsmInsCompanyTenantSort;
|
|
|
import com.jzg.commons.entity.po.SysUploadFiles;
|
|
|
-import com.jzg.commons.entity.system.po.SysSystemBusPerms;
|
|
|
import com.jzg.commons.entity.system.vo.SysSystemBusPermsVo;
|
|
|
import com.jzg.commons.entity.vo.EsmInsCompanyReq;
|
|
|
import com.jzg.commons.entity.vo.EsmInsCompanyResVo;
|
|
|
@@ -15,20 +15,19 @@ import com.jzg.commons.entity.vo.EsmInsCompanyVo;
|
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
|
import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
+import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
import com.jzg.mapper.EsmInsCompanyMapper;
|
|
|
-import com.jzg.mapper.SysSystemBusPermsMapper;
|
|
|
+import com.jzg.mapper.EsmInsCompanyTenantSortMapper;
|
|
|
import com.jzg.service.EsmInsCompanyService;
|
|
|
import com.jzg.service.SysSystemService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -52,6 +51,9 @@ public class EsmInsCompanyServiceImpl extends ServiceImpl<EsmInsCompanyMapper, E
|
|
|
@Autowired
|
|
|
SysSystemService sysSystemService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ EsmInsCompanyTenantSortMapper esmInsCompanyTenantSortMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public List<EsmInsCompanyVo> findTree(EsmInsCompanyReq req) {
|
|
|
List<EsmInsCompanyVo> allList = baseMapper.findTree(req);
|
|
|
@@ -283,6 +285,55 @@ public class EsmInsCompanyServiceImpl extends ServiceImpl<EsmInsCompanyMapper, E
|
|
|
List<EsmInsCompany> esmInsCompanies = baseMapper.selectList(new LambdaQueryWrapper<EsmInsCompany>().in(EsmInsCompany::getId,ids));
|
|
|
return esmInsCompanies;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取保司排序
|
|
|
+ * @param systemCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<EsmInsCompany> getCompanySort(String systemCode) {
|
|
|
+ List<EsmInsCompany> esmInsCompanies = sysSystemService.getUserCompany(systemCode);
|
|
|
+ List<EsmInsCompanyTenantSort> esmInsCompanyTenantSorts = esmInsCompanyTenantSortMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
+ Map<String, Integer> sortMap = esmInsCompanyTenantSorts.stream()
|
|
|
+ .collect(Collectors.toMap(EsmInsCompanyTenantSort::getCompanyId, EsmInsCompanyTenantSort::getOrderNum));
|
|
|
+
|
|
|
+ esmInsCompanies.sort((c1, c2) -> {
|
|
|
+ Integer order1 = sortMap.get(c1.getId());
|
|
|
+ Integer order2 = sortMap.get(c2.getId());
|
|
|
+ if (order1 != null && order2 != null) {
|
|
|
+ return order1.compareTo(order2);
|
|
|
+ } else if (order1 != null) {
|
|
|
+ return -1;
|
|
|
+ } else if (order2 != null) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return esmInsCompanies;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean updateCompanySort(List<EsmInsCompany> companyList, String systemCode) {
|
|
|
+ esmInsCompanyTenantSortMapper.delete(new LambdaQueryWrapper<EsmInsCompanyTenantSort>()
|
|
|
+ .eq(EsmInsCompanyTenantSort::getSystemCode, systemCode));
|
|
|
+
|
|
|
+ List<EsmInsCompanyTenantSort> companyTenantSorts = new ArrayList<>();
|
|
|
+ AtomicInteger orderNum = new AtomicInteger(1);
|
|
|
+ companyList.forEach(item->{
|
|
|
+ EsmInsCompanyTenantSort tenantSort = new EsmInsCompanyTenantSort();
|
|
|
+ tenantSort.setId(IdGenerate.nextId());
|
|
|
+ tenantSort.setCompanyId(item.getId());
|
|
|
+ tenantSort.setOrderNum(orderNum.get());
|
|
|
+ orderNum.getAndIncrement();
|
|
|
+ companyTenantSorts.add(tenantSort);
|
|
|
+ });
|
|
|
+ esmInsCompanyTenantSortMapper.insert(companyTenantSorts);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|