bug修改
This commit is contained in:
parent
d0058f6c48
commit
c37e376c32
@ -199,11 +199,12 @@
|
||||
</select>
|
||||
|
||||
<select id="getTenantListBySn" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser">
|
||||
SELECT a.*, jb.job_name,xr.email,xr.create_time as registryTime
|
||||
SELECT distinct a.*, jb.job_name,xr.email,xr.create_time as registryTime
|
||||
from system_user a
|
||||
join xz_system_user_to_company_project p on p.user_id=a.user_id
|
||||
LEFT JOIN organization_job jb ON a.job_id = jb.id
|
||||
left join xz_registry xr on xr.account=a.account
|
||||
left join xz_registry xr on xr.account=a.account and xr.headquarters_sn=#{map.headquartersSn} and
|
||||
xr.approval_process=2
|
||||
WHERE p.sn = #{map.projectSn} and p.headquarters_sn =#{map.headquartersSn} and a.account_type=10 and p.type = 2
|
||||
order by registryTime desc
|
||||
</select>
|
||||
|
||||
@ -92,4 +92,11 @@ public interface ISystemUserService extends IService<SystemUser> {
|
||||
Page<SystemUser> getSystemUserBySnPage(Map<String, Object> map);
|
||||
|
||||
Map<String, Object> deviceLogin(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 判断是否为供应商
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isSupplier();
|
||||
}
|
||||
|
||||
@ -1445,6 +1445,12 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupplier() {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
return Objects.equals(user.getAccountType(), 11);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String timestamp = "1711613997695";
|
||||
String pw = "123";
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRegion;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRegionMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRegionService;
|
||||
import com.zhgd.xmgl.util.ListUtils;
|
||||
import com.zhgd.xmgl.util.TreeUtil;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -35,7 +32,7 @@ public class HiddenDangerInspectRegionServiceImpl extends ServiceImpl<HiddenDang
|
||||
@Override
|
||||
public List<HiddenDangerInspectRegion> selectHiddenDangerInspectRegion(Map<String, Object> map) {
|
||||
List<HiddenDangerInspectRegion> list = hiddenDangerInspectRegionMapper.selectHiddenDangerInspectRegionList(map);
|
||||
List<HiddenDangerInspectRegion> result = TreeUtil.buildTreeByMap(list, "id", "parentRegion", "children", 0L);
|
||||
List<HiddenDangerInspectRegion> result = ListUtils.buildTreeByMap(list, "id", "parentRegion", "children", 0L);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.zhgd.xmgl.modules.quality.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.quality.entity.QualityRegion;
|
||||
import com.zhgd.xmgl.modules.quality.mapper.QualityRegionMapper;
|
||||
import com.zhgd.xmgl.modules.quality.service.IQualityRegionService;
|
||||
import com.zhgd.xmgl.util.TreeUtil;
|
||||
import com.zhgd.xmgl.util.ListUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -30,7 +30,7 @@ public class QualityRegionServiceImpl extends ServiceImpl<QualityRegionMapper, Q
|
||||
@Override
|
||||
public List<QualityRegion> selectQualityRegionList(Map<String, Object> map) {
|
||||
List<QualityRegion> list = qualityRegionMapper.selectQualityRegionList(map);
|
||||
return TreeUtil.buildTreeByMap(list, "id", "parentRegion", "children", 0L);
|
||||
return ListUtils.buildTreeByMap(list, "id", "parentRegion", "children", 0L);
|
||||
}
|
||||
|
||||
private List<QualityRegion> groupList(List<QualityRegion> list, List<QualityRegion> childList) {
|
||||
|
||||
@ -114,7 +114,8 @@
|
||||
<select id="getXzSupplierByUserId" resultType="com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo"
|
||||
parameterType="map">
|
||||
SELECT
|
||||
a.*,b.user_id,c.company_type_name,b.xz_supplier_type_id,b.project_director_name,b.project_director_phone
|
||||
a.*,b.user_id,c.company_type_name,b.xz_supplier_type_id,b.project_director_name,b.project_director_phone,c.id as
|
||||
enterpriseTypeId
|
||||
from enterprise_info a INNER JOIN xz_user_to_supplier b ON a.id=b.xz_supplier_id
|
||||
LEFT JOIN xz_supplier_type c ON b.xz_supplier_type_id=c.id
|
||||
WHERE b.user_id=#{userId}
|
||||
|
||||
@ -13,12 +13,18 @@
|
||||
group by team_id
|
||||
) b ON a.id=b.team_id
|
||||
WHERE a.project_sn=#{projectSn}
|
||||
<if test="enterpriseId!=null and enterpriseId!=''">
|
||||
<if test="enterpriseId != null and enterpriseId != ''">
|
||||
and a.enterprise_id=#{enterpriseId}
|
||||
</if>
|
||||
<if test="userEnterpriseId!=null and userEnterpriseId!=''">
|
||||
<if test="userEnterpriseId != null and userEnterpriseId != ''">
|
||||
and FIND_IN_SET(a.enterprise_id,#{userEnterpriseId})
|
||||
</if>
|
||||
<if test="enterpriseIds != null and enterpriseIds.size() != 0">
|
||||
and a.id in
|
||||
<foreach collection="enterpriseIds" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectTeamInfoById" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||
select a.*,
|
||||
@ -111,4 +117,4 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@ -14,6 +14,7 @@ import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.base.CompanyVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectEnterpriseMapper;
|
||||
@ -27,19 +28,20 @@ import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.TeamInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.IUserEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzSupplierQualificationApplyServiceImpl;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.ListUtils;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 劳务公司
|
||||
@ -68,6 +70,10 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
private AsyncHikvision asyncHikvision;
|
||||
@Autowired
|
||||
private DepartmentInfoMapper departmentInfoMapper;
|
||||
@Autowired
|
||||
private ISystemUserService systemUserService;
|
||||
@Autowired
|
||||
private XzSupplierQualificationApplyServiceImpl xzSupplierQualificationApplyService;
|
||||
|
||||
@Override
|
||||
public List<EntityMap> getEnterpriseInfoList(Map<String, Object> map) {
|
||||
@ -78,7 +84,28 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
}
|
||||
map.put("enterpriseIds", enterpriseIds);
|
||||
}
|
||||
return enterpriseInfoMapper.getEnterpriseInfoList(map);
|
||||
List<EntityMap> list = enterpriseInfoMapper.getEnterpriseInfoList(map);
|
||||
if (systemUserService.isSupplier()) {
|
||||
return getSupplierEnterprises(list);
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<EntityMap> getSupplierEnterprises(List<EntityMap> list) {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
EnterpriseInfo info = xzSupplierQualificationApplyService.getSupplierInfoByUserId(user.getUserId());
|
||||
Optional<EntityMap> optional = list.stream().filter(entityMap -> entityMap.get("id").equals(info.getId().toString())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
EntityMap infoMap = optional.get();
|
||||
List<EntityMap> childrenAsList = ListUtils.getChildrenAsList(infoMap, list, "id", "parentEnterpriseId");
|
||||
ArrayList<EntityMap> rtList = new ArrayList<>();
|
||||
rtList.add(infoMap);
|
||||
rtList.addAll(childrenAsList);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -226,8 +253,25 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
map.put("enterpriseIds", enterpriseIds);
|
||||
}
|
||||
List<EntityMap> list = enterpriseInfoMapper.getEnterpriseInfoList(map);
|
||||
JSONArray result = ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(list)), "id", "parentEnterpriseId", "children");
|
||||
return result;
|
||||
if (systemUserService.isSupplier()) {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
EnterpriseInfo info = xzSupplierQualificationApplyService.getSupplierInfoByUserId(user.getUserId());
|
||||
Optional<EntityMap> optional = list.stream().filter(entityMap -> entityMap.get("id").equals(info.getId().toString())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
return new JSONArray();
|
||||
}
|
||||
EntityMap infoMap = optional.get();
|
||||
List<EntityMap> childrenAsList = ListUtils.getChildrenAsList(infoMap, list, "id", "parentEnterpriseId");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.add(infoMap);
|
||||
for (EntityMap entityMap : childrenAsList) {
|
||||
jsonArray.add(entityMap);
|
||||
}
|
||||
return ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(jsonArray)), "id", "parentEnterpriseId", "children");
|
||||
} else {
|
||||
JSONArray result = ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(list)), "id", "parentEnterpriseId", "children");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,6 +11,7 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.SystemUserServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
@ -29,10 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 人员班组
|
||||
@ -43,6 +42,10 @@ import java.util.UUID;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> implements ITeamInfoService {
|
||||
@Autowired
|
||||
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||
@Autowired
|
||||
private SystemUserServiceImpl systemUserService;
|
||||
@Autowired
|
||||
private WorkerTypeMapper workerTypeMapper;
|
||||
@Autowired
|
||||
@ -88,7 +91,17 @@ public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> i
|
||||
@Override
|
||||
public Map<String, Object> getTeamInfoList(Map<String, Object> map) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
List<TeamInfo> list = teamInfoMapper.getTeamInfoList(map);
|
||||
List<TeamInfo> list = new ArrayList<>();
|
||||
if (systemUserService.isSupplier()) {
|
||||
List<EntityMap> enterpriseInfoList = enterpriseInfoMapper.getEnterpriseInfoList(map);
|
||||
List<EntityMap> enterprises = enterpriseInfoService.getSupplierEnterprises(enterpriseInfoList);
|
||||
if (CollUtil.isNotEmpty(enterprises)) {
|
||||
map.put("enterpriseIds", enterprises.stream().map(entityMap -> entityMap.get("id")).collect(Collectors.toList()));
|
||||
list = teamInfoMapper.getTeamInfoList(map);
|
||||
}
|
||||
} else {
|
||||
list = teamInfoMapper.getTeamInfoList(map);
|
||||
}
|
||||
data.put("list", list);
|
||||
int totalWorkerNum = 0;
|
||||
for (TeamInfo teamInfo : list) {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.xz.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -168,28 +167,29 @@ public class XzRegistryServiceImpl extends ServiceImpl<XzRegistryMapper, XzRegis
|
||||
//2审批通过3拒绝申请
|
||||
try {
|
||||
if (Objects.equals(approvalProcess, 2)) {
|
||||
SystemUser su = systemUserMapper.selectOne(new LambdaQueryWrapper<SystemUser>()
|
||||
.eq(SystemUser::getAccount, xz.getAccount()));
|
||||
if (su != null) {
|
||||
return;
|
||||
}
|
||||
String projectSns = r.getProjectSns();
|
||||
String companySns = r.getCompanySns();
|
||||
if (StringUtils.isBlank(projectSns) && StringUtils.isBlank(companySns)) {
|
||||
throw new OpenAlertException("审核通过的projectSns和companySns不能同时为空");
|
||||
}
|
||||
SystemUser systemUser = new SystemUser();
|
||||
systemUser.setAccount(xz.getAccount());
|
||||
systemUser.setPassword(xz.getPw());
|
||||
systemUser.setRealName(xz.getAccount());
|
||||
systemUser.setAccountType(10);
|
||||
systemUser.setHeadquartersSn(null);//无关
|
||||
SystemUser su = systemUserMapper.selectOne(new LambdaQueryWrapper<SystemUser>()
|
||||
.eq(SystemUser::getAccount, xz.getAccount()));
|
||||
Long userId = null;
|
||||
try {
|
||||
userId = systemUserService.saveSystemUser(systemUser);
|
||||
} catch (DuplicateKeyException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
if (su == null) {
|
||||
SystemUser systemUser = new SystemUser();
|
||||
systemUser.setAccount(xz.getAccount());
|
||||
systemUser.setPassword(xz.getPw());
|
||||
systemUser.setRealName(xz.getAccount());
|
||||
systemUser.setAccountType(10);
|
||||
systemUser.setHeadquartersSn(null);//无关
|
||||
try {
|
||||
userId = systemUserService.saveSystemUser(systemUser);
|
||||
} catch (DuplicateKeyException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
userId = su.getUserId();
|
||||
}
|
||||
//处理组织权限
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
@ -16,7 +16,10 @@ import com.zhgd.xmgl.modules.basicdata.entity.XzSystemUserToCompanyProject;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.XzSystemUserToCompanyProjectMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.CompanyServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectEnterpriseMapper;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzSupplierQualification;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzSupplierQualificationApply;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzSupplierQualificationRecord;
|
||||
@ -29,6 +32,7 @@ import com.zhgd.xmgl.modules.xz.service.IXzSupplierQualificationApplyService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -47,6 +51,8 @@ public class XzSupplierQualificationApplyServiceImpl extends ServiceImpl<XzSuppl
|
||||
@Autowired
|
||||
private XzSystemUserToCompanyProjectMapper xzSystemUserToCompanyProjectMapper;
|
||||
@Autowired
|
||||
private ProjectEnterpriseMapper projectEnterpriseMapper;
|
||||
@Autowired
|
||||
private XzSupplierQualificationApplyMapper xzSupplierQualificationApplyMapper;
|
||||
@Autowired
|
||||
private XzSupplierQualificationRecordMapper xzSupplierQualificationRecordMapper;
|
||||
@ -60,6 +66,8 @@ public class XzSupplierQualificationApplyServiceImpl extends ServiceImpl<XzSuppl
|
||||
private CompanyServiceImpl companyService;
|
||||
@Autowired
|
||||
private CompanyMapper companyMapper;
|
||||
@Autowired
|
||||
private EnterpriseInfoMapper enterpriseInfoMapper;
|
||||
|
||||
@Override
|
||||
public IPage<XzSupplierQualificationApply> queryPageList(HashMap<String, Object> paramMap) {
|
||||
@ -116,7 +124,7 @@ public class XzSupplierQualificationApplyServiceImpl extends ServiceImpl<XzSuppl
|
||||
if (headquarterCompany == null) {
|
||||
throw new OpenAlertException("总公司为空");
|
||||
}
|
||||
|
||||
EnterpriseInfo ei = getSupplierInfoByUserId(applyUserId);
|
||||
//添加之前已经分配的权限
|
||||
Set<String> projectSnList = new HashSet<>();
|
||||
projectSnList.add(projectSn);
|
||||
@ -140,10 +148,30 @@ public class XzSupplierQualificationApplyServiceImpl extends ServiceImpl<XzSuppl
|
||||
paramMap.put("headquartersSn", headquartersSn);
|
||||
paramMap.put("projectSns", StrUtil.join(",", projectSnList));
|
||||
companyService.updateTenantOrg(paramMap);
|
||||
|
||||
//插入企业关联
|
||||
ProjectEnterprise projectEnterprise = new ProjectEnterprise();
|
||||
projectEnterprise.setProjectSn(projectSn);
|
||||
projectEnterprise.setEnterpriseId(ei.getId());
|
||||
projectEnterprise.setEnterpriseTypeId(ei.getEnterpriseTypeId());
|
||||
projectEnterprise.setType(1);
|
||||
projectEnterprise.setParentEnterpriseId(0L);
|
||||
projectEnterpriseMapper.insert(projectEnterprise);
|
||||
}
|
||||
baseMapper.updateById(xzSupplierQualificationApply);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EnterpriseInfo getSupplierInfoByUserId(Long applyUserId) {
|
||||
Map<String, Object> eiMap = new HashMap<>();
|
||||
eiMap.put("userId", applyUserId);
|
||||
EnterpriseInfo ei = enterpriseInfoMapper.getXzSupplierByUserId(eiMap);
|
||||
if (ei == null) {
|
||||
throw new OpenAlertException("请先填写供应商信息");
|
||||
}
|
||||
return ei;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
XzSupplierQualificationApply xzSupplierQualificationApply = baseMapper.selectById(id);
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @program: wisdomSite
|
||||
@ -14,8 +26,9 @@ public class ListUtils {
|
||||
|
||||
/**
|
||||
* 数据归类
|
||||
* @param arr 需要归类的数据
|
||||
* @param id 本数据和父级关联的字段名
|
||||
*
|
||||
* @param arr 需要归类的数据
|
||||
* @param id 本数据和父级关联的字段名
|
||||
* @param pid 父级的字段名
|
||||
* @param child 归类的的集合存放的字段
|
||||
* @return
|
||||
@ -52,9 +65,181 @@ public class ListUtils {
|
||||
hashVP.put(child, ch);
|
||||
}
|
||||
} else {
|
||||
if (arr.size() == 1) {
|
||||
aVal.put(child, new JSONArray());
|
||||
}
|
||||
r.add(aVal);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过Map方式构建树
|
||||
*
|
||||
* @param list 列表
|
||||
* @return {@link List}<{@link T}>
|
||||
*/
|
||||
public static <T> List<T> buildTreeByMap(List<T> list) {
|
||||
return buildTreeByMap(list, "id", "parentId", "children", "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过Map方式构建树
|
||||
*
|
||||
* @param list 列表
|
||||
* @param idName id名称
|
||||
* @param parentIdName 父id名称
|
||||
* @param childrenName 子节点列表名称
|
||||
* @param topParentIdVal 顶层节点父id的值
|
||||
* @return {@link List}<{@link T}>
|
||||
*/
|
||||
public static <T> List<T> buildTreeByMap(List<T> list, String idName, String parentIdName, String childrenName, Object topParentIdVal) {
|
||||
if (StringUtils.isBlank(idName) || StringUtils.isBlank(parentIdName) || StringUtils.isBlank(childrenName)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//根据parentId进行分组
|
||||
Map<String, List<T>> mapList = list.stream().collect(Collectors.groupingBy(o -> getFieldValue(o, parentIdName).toString()));
|
||||
//给每个节点设置子节点列表
|
||||
list.forEach(node -> setFieldValue(node, mapList.get(getFieldValue(node, idName).toString()), childrenName));
|
||||
return list.stream().filter(o -> topParentIdVal.equals(getFieldValue(o, parentIdName))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性值
|
||||
*
|
||||
* @param o 对象
|
||||
* @param fieldName 属性名
|
||||
* @return {@link String}
|
||||
*/
|
||||
private static Object getFieldValue(Object o, String fieldName) {
|
||||
try {
|
||||
if (o instanceof EntityMap) {
|
||||
return ((EntityMap) o).get(fieldName);
|
||||
} else {
|
||||
Class<?> oClass = o.getClass();
|
||||
Field field = oClass.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return field.get(o);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置字段值
|
||||
*
|
||||
* @param o 对象
|
||||
* @param val 值
|
||||
* @param fieldName 属性名
|
||||
*/
|
||||
private static void setFieldValue(Object o, Object val, String fieldName) {
|
||||
try {
|
||||
if (o instanceof EntityMap) {
|
||||
((EntityMap) o).put(fieldName, val);
|
||||
} else {
|
||||
Class<?> oClass = o.getClass();
|
||||
Field field = oClass.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(o, val);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归查询该节点的子节点列表(不包含自己)
|
||||
*
|
||||
* @param root 该节点
|
||||
* @param allList 所有节点列表
|
||||
*/
|
||||
public static <T> List<T> getChildrenAsList(T root, List<T> allList, String idName, String parentIdName) {
|
||||
List<T> list = new ArrayList<>();
|
||||
List<T> childrenList = allList.stream()
|
||||
.filter(m -> Objects.equals(getFieldValue(m, parentIdName), getFieldValue(root, idName)))
|
||||
.peek(m -> list.addAll(getChildrenAsList(m, allList, idName, parentIdName)))
|
||||
.collect(Collectors.toList());
|
||||
list.addAll(childrenList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询当前节点的子节点列表(包含自己)
|
||||
*
|
||||
* @param curNode
|
||||
* @param rsList 返回结果
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
*/
|
||||
public static <T> void reversionTreeToList(T curNode, List<T> rsList, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
Class<T> aClass = (Class<T>) curNode.getClass();
|
||||
rsList.add(BeanUtil.toBean(curNode, aClass));
|
||||
List<T> subCityList = (List<T>) getFieldValue(curNode, childrenName);
|
||||
if (subCityList != null && !subCityList.isEmpty()) {
|
||||
for (T city : subCityList) { //递归寻找子节点的子节点们
|
||||
reversionTreeToList(city, rsList, idName, parentIdName, childrenName, topParentIdVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tree转list
|
||||
*
|
||||
* @param treeList
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
*/
|
||||
public static <T> List<T> treeToList(List<T> treeList, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
List<T> list = new ArrayList<>();
|
||||
//这一层for的目的是:遍历根节点
|
||||
for (T t : treeList) {
|
||||
reversionTreeToList(t, list, idName, parentIdName, childrenName, topParentIdVal);
|
||||
}
|
||||
for (T t : list) {
|
||||
setFieldValue(t, null, childrenName);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前节点的祖级节点列表(不包含自己)
|
||||
*
|
||||
* @param allList 所有节点列表
|
||||
* @param id 该节点id的值
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> getParentList(List<T> allList, Object id, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
List<T> rsList = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(allList)) {
|
||||
return rsList;
|
||||
}
|
||||
Map<Object, T> idMap = allList.stream().collect(Collectors.toMap(o -> getFieldValue(o, idName), Function.identity()));
|
||||
T t = idMap.get(id);
|
||||
if (t == null) {
|
||||
return rsList;
|
||||
}
|
||||
T p = idMap.get(getFieldValue(t, parentIdName));
|
||||
while (p != null) {
|
||||
rsList.add(p);
|
||||
p = idMap.get(getFieldValue(p, parentIdName));
|
||||
}
|
||||
for (T t1 : rsList) {
|
||||
setFieldValue(t1, null, childrenName);
|
||||
}
|
||||
return rsList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,181 +0,0 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 构建Tree
|
||||
*/
|
||||
public class TreeUtil {
|
||||
|
||||
/**
|
||||
* 通过Map方式构建树
|
||||
*
|
||||
* @param list 列表
|
||||
* @return {@link List}<{@link T}>
|
||||
*/
|
||||
public static <T> List<T> buildTreeByMap(List<T> list) {
|
||||
return buildTreeByMap(list, "id", "parentId", "children", "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过Map方式构建树
|
||||
*
|
||||
* @param list 列表
|
||||
* @param idName id名称
|
||||
* @param parentIdName 父id名称
|
||||
* @param childrenName 子节点列表名称
|
||||
* @param topParentIdVal 顶层节点父id的值
|
||||
* @return {@link List}<{@link T}>
|
||||
*/
|
||||
public static <T> List<T> buildTreeByMap(List<T> list, String idName, String parentIdName, String childrenName, Object topParentIdVal) {
|
||||
if (StringUtils.isBlank(idName) || StringUtils.isBlank(parentIdName) || StringUtils.isBlank(childrenName)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//根据parentId进行分组
|
||||
Map<String, List<T>> mapList = list.stream().collect(Collectors.groupingBy(o -> getFieldValue(o, parentIdName).toString()));
|
||||
//给每个节点设置子节点列表
|
||||
list.forEach(node -> setFieldValue(node, mapList.get(getFieldValue(node, idName).toString()), childrenName));
|
||||
return list.stream().filter(o -> topParentIdVal.equals(getFieldValue(o, parentIdName))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性值
|
||||
*
|
||||
* @param o 对象
|
||||
* @param fieldName 属性名
|
||||
* @return {@link String}
|
||||
*/
|
||||
private static Object getFieldValue(Object o, String fieldName) {
|
||||
try {
|
||||
Class<?> oClass = o.getClass();
|
||||
Field field = oClass.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return field.get(o);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置字段值
|
||||
*
|
||||
* @param o 对象
|
||||
* @param val 值
|
||||
* @param fieldName 属性名
|
||||
*/
|
||||
private static void setFieldValue(Object o, Object val, String fieldName) {
|
||||
try {
|
||||
Class<?> oClass = o.getClass();
|
||||
Field field = oClass.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(o, val);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归查询该节点的子节点列表(不包含自己)
|
||||
*
|
||||
* @param root 该节点
|
||||
* @param allList 所有节点列表
|
||||
*/
|
||||
public static <T> List<T> getChildrenAsList(T root, List<T> allList, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
List<T> list = new ArrayList<>();
|
||||
List<T> childrenList = allList.stream()
|
||||
.filter(m -> Objects.equals(getFieldValue(m, parentIdName), getFieldValue(root, idName)))
|
||||
.peek(m -> list.addAll(getChildrenAsList(m, allList, idName, parentIdName, childrenName, topParentIdVal)))
|
||||
.collect(Collectors.toList());
|
||||
list.addAll(childrenList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询当前节点的子节点列表(包含自己)
|
||||
*
|
||||
* @param curNode
|
||||
* @param rsList 返回结果
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
*/
|
||||
public static <T> void reversionTreeToList(T curNode, List<T> rsList, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
Class<T> aClass = (Class<T>) curNode.getClass();
|
||||
rsList.add(BeanUtil.toBean(curNode, aClass));
|
||||
List<T> subCityList = (List<T>) getFieldValue(curNode, childrenName);
|
||||
if (subCityList != null && !subCityList.isEmpty()) {
|
||||
for (T city : subCityList) { //递归寻找子节点的子节点们
|
||||
reversionTreeToList(city, rsList, idName, parentIdName, childrenName, topParentIdVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tree转list
|
||||
*
|
||||
* @param treeList
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
*/
|
||||
public static <T> List<T> treeToList(List<T> treeList, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
List<T> list = new ArrayList<>();
|
||||
//这一层for的目的是:遍历根节点
|
||||
for (T t : treeList) {
|
||||
reversionTreeToList(t, list, idName, parentIdName, childrenName, topParentIdVal);
|
||||
}
|
||||
for (T t : list) {
|
||||
setFieldValue(t, null, childrenName);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前节点的祖级节点列表(不包含自己)
|
||||
*
|
||||
* @param allList 所有节点列表
|
||||
* @param id 该节点id的值
|
||||
* @param idName
|
||||
* @param parentIdName
|
||||
* @param childrenName
|
||||
* @param topParentIdVal
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> getParentList(List<T> allList, Object id, String idName, String parentIdName, String childrenName, String topParentIdVal) {
|
||||
List<T> rsList = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(allList)) {
|
||||
return rsList;
|
||||
}
|
||||
Map<Object, T> idMap = allList.stream().collect(Collectors.toMap(o -> getFieldValue(o, idName), Function.identity()));
|
||||
T t = idMap.get(id);
|
||||
if (t == null) {
|
||||
return rsList;
|
||||
}
|
||||
T p = idMap.get(getFieldValue(t, parentIdName));
|
||||
while (p != null) {
|
||||
rsList.add(p);
|
||||
p = idMap.get(getFieldValue(p, parentIdName));
|
||||
}
|
||||
for (T t1 : rsList) {
|
||||
setFieldValue(t1, null, childrenName);
|
||||
}
|
||||
return rsList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user