Commit 362f826e by 赵剑炜

修复接口测试BUG

parent 8fe59493
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/jyzb-api/jyzb-api.iml" filepath="$PROJECT_DIR$/jyzb-api/jyzb-api.iml" />
<module fileurl="file://$PROJECT_DIR$/jyzb-biz/jyzb-biz.iml" filepath="$PROJECT_DIR$/jyzb-biz/jyzb-biz.iml" /> <module fileurl="file://$PROJECT_DIR$/jyzb-biz/jyzb-biz.iml" filepath="$PROJECT_DIR$/jyzb-biz/jyzb-biz.iml" />
<module fileurl="file://$PROJECT_DIR$/jyzb-boot/jyzb-boot.iml" filepath="$PROJECT_DIR$/jyzb-boot/jyzb-boot.iml" /> <module fileurl="file://$PROJECT_DIR$/jyzb-boot/jyzb-boot.iml" filepath="$PROJECT_DIR$/jyzb-boot/jyzb-boot.iml" />
<module fileurl="file://$PROJECT_DIR$/jyzb-mq/jyzb-mq-consumer/jyzb-mq-consumer.iml" filepath="$PROJECT_DIR$/jyzb-mq/jyzb-mq-consumer/jyzb-mq-consumer.iml" /> <module fileurl="file://$PROJECT_DIR$/jyzb-mq/jyzb-mq-consumer/jyzb-mq-consumer.iml" filepath="$PROJECT_DIR$/jyzb-mq/jyzb-mq-consumer/jyzb-mq-consumer.iml" />
......
...@@ -10,6 +10,7 @@ public class EquipmentTreeDto { ...@@ -10,6 +10,7 @@ public class EquipmentTreeDto {
private String name; private String name;
private String code; private String code;
private Integer type; private Integer type;
private String parentId;
private List<EquipmentTreeDto> child = new ArrayList<>(); private List<EquipmentTreeDto> child = new ArrayList<>();
public void addChild(EquipmentTreeDto child) { public void addChild(EquipmentTreeDto child) {
this.child.add(child); this.child.add(child);
......
...@@ -9,6 +9,8 @@ public class EquipmentTypeDto { ...@@ -9,6 +9,8 @@ public class EquipmentTypeDto {
private String name; private String name;
private String unit; private String unit;
private String unitType; private String unitType;
private String parentId;
private String code;
private Integer state; private Integer state;
private Integer type; private Integer type;
private String warrantyPeriod; private String warrantyPeriod;
......
...@@ -10,11 +10,11 @@ import javax.validation.constraints.NotNull; ...@@ -10,11 +10,11 @@ import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) //@EqualsAndHashCode(callSuper = false)
public class QueryEquipmentTypeReq extends BaseRequest { public class QueryEquipmentTypeReq {
private String id; private String id;
private String code; private String code;
private String parentId;
private Integer type;
} }
...@@ -9,10 +9,11 @@ import java.util.Date; ...@@ -9,10 +9,11 @@ import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true)
public class QuerySupplierReq extends BaseRequest { public class QuerySupplierReq {
private String name; private String name;
private String id;
private String code; private String code;
......
...@@ -23,6 +23,6 @@ public class UpdateEquipmentSizeReq { ...@@ -23,6 +23,6 @@ public class UpdateEquipmentSizeReq {
private String note; private String note;
private BigDecimal price; private BigDecimal price;
@NotBlank(message = "状态值不能为空", groups = {ValidationApi.edit.class}) @NotBlank(message = "状态值不能为空", groups = {ValidationApi.updateStatus.class})
private String state; private String state;
} }
...@@ -62,7 +62,7 @@ public class EquipmentSizeController { ...@@ -62,7 +62,7 @@ public class EquipmentSizeController {
@PostMapping("/ChangeSizeState") @PostMapping("/ChangeSizeState")
@ApiOperation("禁用/启用装备号型") @ApiOperation("禁用/启用装备号型")
public ApiRes<Boolean> changeSizeState(@RequestBody @Validated(ValidationApi.edit.class) UpdateEquipmentSizeReq req) { public ApiRes<Boolean> changeSizeState(@RequestBody @Validated(ValidationApi.updateStatus.class) UpdateEquipmentSizeReq req) {
return ApiRes.success(equipmentSizeService.changeSizeState(req)); return ApiRes.success(equipmentSizeService.changeSizeState(req));
} }
......
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import cn.hutool.core.util.ObjectUtil;
import com.junmp.jyzb.api.bean.dto.EquipmentTreeDto; import com.junmp.jyzb.api.bean.dto.EquipmentTreeDto;
import com.junmp.jyzb.api.bean.dto.EquipmentTypeDto; import com.junmp.jyzb.api.bean.dto.EquipmentTypeDto;
import com.junmp.jyzb.api.bean.dto.OrgDto;
import com.junmp.jyzb.api.bean.query.QueryEquipmentTypeReq; import com.junmp.jyzb.api.bean.query.QueryEquipmentTypeReq;
import com.junmp.jyzb.api.bean.query.QueryOrgReq;
import com.junmp.jyzb.api.bean.req.UpdateEquipmentTypeReq; import com.junmp.jyzb.api.bean.req.UpdateEquipmentTypeReq;
import com.junmp.jyzb.entity.PubOrg;
import com.junmp.jyzb.service.EquipmentTypeService; import com.junmp.jyzb.service.EquipmentTypeService;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.common.bean.request.ValidationApi; import com.junmp.v2.common.bean.request.ValidationApi;
...@@ -47,7 +51,7 @@ public class EquipmentTypeController { ...@@ -47,7 +51,7 @@ public class EquipmentTypeController {
@PostMapping("/ShowEquipmentList") @PostMapping("/ShowEquipmentList")
@ApiOperation("查询类别列表") @ApiOperation("查询类别列表")
public ApiRes<List<EquipmentTreeDto>> ShowEquipmentList(@RequestBody QueryEquipmentTypeReq req) { public ApiRes<List<EquipmentTypeDto>> ShowEquipmentList(@RequestBody QueryEquipmentTypeReq req) {
return ApiRes.success(equipmentTypeService.getEquipmentList(req)); return ApiRes.success(equipmentTypeService.getEquipmentList(req));
} }
...@@ -57,6 +61,12 @@ public class EquipmentTypeController { ...@@ -57,6 +61,12 @@ public class EquipmentTypeController {
public ApiRes<EquipmentTypeDto> getEquipment(@RequestBody QueryEquipmentTypeReq req) { public ApiRes<EquipmentTypeDto> getEquipment(@RequestBody QueryEquipmentTypeReq req) {
return ApiRes.success( equipmentTypeService.getEquipment(req)); return ApiRes.success( equipmentTypeService.getEquipment(req));
} }
@PostMapping("/getLowType")
@ApiOperation("根据上级物资查询下一级信息")
public ApiRes<List<EquipmentTypeDto>> getLowType(@RequestBody QueryEquipmentTypeReq req) {
return ApiRes.success(equipmentTypeService.getLowType(req)) ;
}
@PostMapping("/UpdateEquipment") @PostMapping("/UpdateEquipment")
@ApiOperation("修改物资信息") @ApiOperation("修改物资信息")
......
...@@ -44,8 +44,8 @@ public class PubOrgController { ...@@ -44,8 +44,8 @@ public class PubOrgController {
} }
@PostMapping("/GetOrgList") @PostMapping("/GetOrgList")
@ApiOperation("查询组织树形结构") @ApiOperation("查询组织机构列表")
public ApiRes<List<OrgTreeDto>> getOrgList(@RequestBody QueryOrgReq req) { public ApiRes<List<OrgDto>> getOrgList(@RequestBody QueryOrgReq req) {
return ApiRes.success(pubOrgService.getOrgList(req)); return ApiRes.success(pubOrgService.getOrgList(req));
} }
@PostMapping("/ChangeOrgState") @PostMapping("/ChangeOrgState")
......
...@@ -41,20 +41,20 @@ public class SupplierController { ...@@ -41,20 +41,20 @@ public class SupplierController {
@PostMapping("/ShowSupplier") @PostMapping("/ShowSupplier")
@ApiOperation("查询供应商列表") @ApiOperation("查询供应商列表")
public ApiRes<List<SupplierDto>> ShowSupplier(QuerySupplierReq req){ public ApiRes<List<SupplierDto>> ShowSupplier(@RequestBody QuerySupplierReq req){
return ApiRes.success(supplierService.ShowSupplier(req)); return ApiRes.success(supplierService.ShowSupplier(req));
} }
@PostMapping("/UpdateSupplier") @PostMapping("/UpdateSupplier")
@ApiOperation("修改供应商信息") @ApiOperation("修改供应商信息")
public ApiRes<Boolean> updateSupplier(@RequestBody @Validated(QuerySupplierReq.edit.class) UpdateSupplierReq req) { public ApiRes<Boolean> updateSupplier(@RequestBody @Validated(ValidationApi.edit.class) UpdateSupplierReq req) {
return ApiRes.success(supplierService.UpdateSupplier(req)); return ApiRes.success(supplierService.UpdateSupplier(req));
} }
@PostMapping("/ChangeSupplierState") @PostMapping("/ChangeSupplierState")
@ApiOperation("修改供应商状态") @ApiOperation("修改供应商状态")
public ApiRes<Boolean> changeSupplierState(@RequestBody @Validated(QuerySupplierReq.edit.class) UpdateSupplierReq req) { public ApiRes<Boolean> changeSupplierState(@RequestBody @Validated(ValidationApi.edit.class) UpdateSupplierReq req) {
return ApiRes.success(supplierService.ChangeSupplierState(req)); return ApiRes.success(supplierService.ChangeSupplierState(req));
} }
} }
...@@ -74,6 +74,17 @@ public class EquipmentType implements Serializable { ...@@ -74,6 +74,17 @@ public class EquipmentType implements Serializable {
private Integer state; private Integer state;
/** /**
* 当前状态:0关闭/1启用
*/
@TableField("warranty_period")
private Integer warrantyPeriod;
/**
* 当前状态:0关闭/1启用
*/
@TableField("maintenance_period")
private Integer maintenancePeriod;
/**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
......
...@@ -22,10 +22,11 @@ public interface EquipmentTypeService extends IService<EquipmentType> { ...@@ -22,10 +22,11 @@ public interface EquipmentTypeService extends IService<EquipmentType> {
Boolean changeEquipmentState(UpdateEquipmentTypeReq req); Boolean changeEquipmentState(UpdateEquipmentTypeReq req);
List<EquipmentTreeDto> getEquipmentList(QueryEquipmentTypeReq req); List<EquipmentTypeDto> getEquipmentList(QueryEquipmentTypeReq req);
EquipmentTypeDto getEquipment(QueryEquipmentTypeReq req ); EquipmentTypeDto getEquipment(QueryEquipmentTypeReq req );
List<EquipmentTypeDto> getLowType(QueryEquipmentTypeReq orgId);
ResponseResult setTypeParentIds(); ResponseResult setTypeParentIds();
......
...@@ -20,7 +20,7 @@ public interface PubOrgService extends IService<PubOrg> { ...@@ -20,7 +20,7 @@ public interface PubOrgService extends IService<PubOrg> {
ResponseResult setOrgParentIds(); ResponseResult setOrgParentIds();
List<OrgTreeDto> getOrgList(QueryOrgReq req); List<OrgDto> getOrgList(QueryOrgReq req);
List<OrgDto> getLowOrg(QueryOrgReq req); List<OrgDto> getLowOrg(QueryOrgReq req);
Boolean ChangeState(UpdateOrgReq req); Boolean ChangeState(UpdateOrgReq req);
......
...@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.junmp.jyzb.api.bean.dto.EquipmentTreeDto; import com.junmp.jyzb.api.bean.dto.EquipmentTreeDto;
import com.junmp.jyzb.api.bean.dto.EquipmentTypeDto; import com.junmp.jyzb.api.bean.dto.EquipmentTypeDto;
import com.junmp.jyzb.api.bean.dto.OrgDto;
import com.junmp.jyzb.api.bean.query.QueryEquipmentTypeReq; import com.junmp.jyzb.api.bean.query.QueryEquipmentTypeReq;
import com.junmp.jyzb.api.bean.query.QueryOrgReq;
import com.junmp.jyzb.api.bean.req.UpdateEquipmentTypeReq; import com.junmp.jyzb.api.bean.req.UpdateEquipmentTypeReq;
import com.junmp.jyzb.api.exception.JYZBAppException; import com.junmp.jyzb.api.exception.JYZBAppException;
import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum; import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum;
...@@ -48,79 +50,17 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E ...@@ -48,79 +50,17 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
private static final String REDIS_TYPE = "Type_"; private static final String REDIS_TYPE = "Type_";
public List<EquipmentTreeDto> getEquipmentList(QueryEquipmentTypeReq req) { public List<EquipmentTypeDto> getEquipmentList(QueryEquipmentTypeReq req) {
String selfCode="00000000-0000-0000-0000-000000000000"; LambdaQueryWrapper<EquipmentType> wp= this.createWrapper(req);
List<EquipmentType> list = this.list(wp);
List<EquipmentTypeDto> orgs=new ArrayList<>();
list.forEach(p->{
EquipmentTypeDto org=new EquipmentTypeDto();
BeanPlusUtil.copyProperties(p, org);
List<EquipmentTreeDto> equipmentTypeDTOList = new ArrayList<>(); orgs.add(org);
LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>(); });
String setNewCode=""; return orgs;
if (ObjectUtil.isNotEmpty(req.getCode())) {
{
setNewCode=req.getCode().replaceAll("0+$", "");
}
}
wrapper.likeRight(ObjectUtil.isNotEmpty(req.getCode()), EquipmentType::getCode, setNewCode);
List<EquipmentType> equipmentList = this.list(wrapper);
// 创建一个 Map 来存储 Equipment ID 和对应的 DTO 对象
Map<String, EquipmentTreeDto> equipmentDtoMap = new HashMap<>();
// 创建一个 Map 来存储父类的 parentid 和对应的父类节点
Map<String, EquipmentTreeDto> parentDtoMap = new HashMap<>();
if (ObjectUtil.isNotEmpty(req.getCode())&&!req.getCode().equals("00000000-0000-0000-0000-000000000000"))
{ LambdaQueryWrapper<EquipmentType> wrapper2 = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(req.getCode()))
{
selfCode=req.getCode();
}
wrapper2.eq(ObjectUtil.isNotEmpty(req.getCode()), EquipmentType::getCode, selfCode);
String id= this.getOne(wrapper2).getId();
selfCode=id;
EquipmentType et=this.getById(id);
EquipmentTreeDto equipmentTypeDTO = new EquipmentTreeDto();
equipmentTypeDTO.setName(et.getName());
equipmentTypeDTO.setCode(et.getCode());
equipmentTypeDTO.setType(et.getType());
equipmentDtoMap.put(et.getId(),equipmentTypeDTO);
}
// 第一轮遍历:创建 EquipmentTreeDto 对象并将其加入到 Map 中
for (EquipmentType equipment : equipmentList) {
EquipmentTreeDto equipmentTypeDTO = new EquipmentTreeDto();
equipmentTypeDTO.setName(equipment.getName());
equipmentTypeDTO.setCode(equipment.getCode());
equipmentTypeDTO.setType(equipment.getType());
equipmentDtoMap.put(equipment.getId(), equipmentTypeDTO);
// 如果 parentid 是传进来的值,则将其作为顶级节点添加到 equipmentTypeDTOList 中
if (equipment.getId().equals(selfCode)) {
equipmentTypeDTOList.add(equipmentTypeDTO);
}
}
// 第二轮遍历:将子节点连接到父节点
boolean isStartAddingChildren = false;
for (EquipmentType equipment : equipmentList) {
String parentId = equipment.getParentId();
EquipmentTreeDto equipmentTypeDTO = equipmentDtoMap.get(equipment.getId());
// 如果找到传入的ID对应的节点,则开始添加子节点
if (equipment.getId().equals(selfCode)) {
isStartAddingChildren = true;
}
// 如果 isStartAddingChildren 为 true,并且 parentDtoMap 中有对应的父类节点,则将节点连接到父节点
if (isStartAddingChildren && parentDtoMap.containsKey(parentId)) {
EquipmentTreeDto parentDto = parentDtoMap.get(parentId);
parentDto.addChild(equipmentTypeDTO);
}
// 将当前节点添加到 parentDtoMap 中,以便后续节点连接
parentDtoMap.put(equipment.getId(), equipmentTypeDTO);
}
return equipmentTypeDTOList;
} }
...@@ -139,6 +79,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E ...@@ -139,6 +79,7 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
EquipmentType parentType = this.getById(req.getParentId()); EquipmentType parentType = this.getById(req.getParentId());
int newcode = parentType.getMaxCode() + 1; int newcode = parentType.getMaxCode() + 1;
type.setId(String.valueOf(newcode)); type.setId(String.valueOf(newcode));
type.setCode(String.valueOf(newcode));
parentType.setMaxCode(newcode); parentType.setMaxCode(newcode);
parentType.setCode(String.valueOf(newcode)); parentType.setCode(String.valueOf(newcode));
List<SupplierType> supplierType = new ArrayList<>(); List<SupplierType> supplierType = new ArrayList<>();
...@@ -263,7 +204,40 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E ...@@ -263,7 +204,40 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
BeanPlusUtil.copyProperties(this.getById(req.getId()), equipment); BeanPlusUtil.copyProperties(this.getById(req.getId()), equipment);
return equipment; return equipment;
} }
public List<EquipmentTypeDto> getLowType(QueryEquipmentTypeReq req){
if (ObjectUtil.isEmpty(req.getParentId())) {
req.setParentId(req.getId());
}
if (ObjectUtil.isEmpty(req.getParentId())) {
req.setParentId("00000000-0000-0000-0000-000000000000");
}
LambdaQueryWrapper<EquipmentType> wp= this.createWrapper(req);
List<EquipmentType> list = this.list(wp);
List<EquipmentTypeDto> orgs=new ArrayList<>();
Comparator<EquipmentType> orgComparator = (org1, org2) -> {
String code1 = org1.getCode();
String code2 = org2.getCode();
// 将code字段转换为整数类型进行比较
try {
long intValue1 = Long.parseLong(code1);
long intValue2 = Long.parseLong(code2);
return Long.compare(intValue1, intValue2);
} catch (NumberFormatException e) {
// 如果有不是数字的情况,直接返回字符串比较结果
return code1.compareTo(code2);
}
};
Collections.sort(list, orgComparator);
list.forEach(p->{
EquipmentTypeDto org=new EquipmentTypeDto();
BeanPlusUtil.copyProperties(p, org);
orgs.add(org);
});
return orgs;
}
@Override @Override
public ResponseResult setTypeParentIds() { public ResponseResult setTypeParentIds() {
...@@ -280,6 +254,10 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E ...@@ -280,6 +254,10 @@ public class EquipmentTypeServiceImpl extends ServiceImpl<EquipmentTypeMapper, E
if (ObjectUtil.isEmpty(req)) { if (ObjectUtil.isEmpty(req)) {
return wrapper; return wrapper;
} }
wrapper.eq(ObjectUtil.isNotEmpty(req.getParentId()), EquipmentType::getParentId,req.getParentId() );
// 添加id字段不等于"00000000-0000-0000-0000-000000000000"的判断
wrapper.ne(EquipmentType::getId, "00000000-0000-0000-0000-000000000000");
wrapper.eq(ObjectUtil.isNotEmpty(req.getType()), EquipmentType::getType,req.getType() );
wrapper.orderByDesc(EquipmentType::getCreateTime); wrapper.orderByDesc(EquipmentType::getCreateTime);
return wrapper; return wrapper;
......
...@@ -3,6 +3,7 @@ package com.junmp.jyzb.service.impl; ...@@ -3,6 +3,7 @@ package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.EquipmentTypeDto;
import com.junmp.jyzb.api.bean.dto.OrgDto; import com.junmp.jyzb.api.bean.dto.OrgDto;
import com.junmp.jyzb.api.bean.dto.OrgTreeDto; import com.junmp.jyzb.api.bean.dto.OrgTreeDto;
import com.junmp.jyzb.api.bean.query.QueryOrgReq; import com.junmp.jyzb.api.bean.query.QueryOrgReq;
...@@ -10,6 +11,7 @@ import com.junmp.jyzb.api.bean.req.UpdateOrgReq; ...@@ -10,6 +11,7 @@ import com.junmp.jyzb.api.bean.req.UpdateOrgReq;
import com.junmp.jyzb.api.exception.JYZBAppException; import com.junmp.jyzb.api.exception.JYZBAppException;
import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum; import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum;
import com.junmp.jyzb.api.exception.enums.OrgExceptionEnum; import com.junmp.jyzb.api.exception.enums.OrgExceptionEnum;
import com.junmp.jyzb.entity.EquipmentType;
import com.junmp.jyzb.entity.PubOrg; import com.junmp.jyzb.entity.PubOrg;
import com.junmp.jyzb.entity.Supplier; import com.junmp.jyzb.entity.Supplier;
import com.junmp.jyzb.utils.HttpStatus; import com.junmp.jyzb.utils.HttpStatus;
...@@ -329,72 +331,18 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -329,72 +331,18 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
return orgs; return orgs;
} }
public List<OrgTreeDto> getOrgList(QueryOrgReq req) { public List<OrgDto> getOrgList(QueryOrgReq req) {
String selfCode = "1369509498032808905"; LambdaQueryWrapper<PubOrg> wp= this.createWrapper(req);
List<OrgTreeDto> orgDTOList = new ArrayList<>(); List<PubOrg> list = this.list(wp);
LambdaQueryWrapper<PubOrg> wrapper = new LambdaQueryWrapper<>(); List<OrgDto> orgs=new ArrayList<>();
String setNewCode; list.forEach(p->{
if (ObjectUtil.isNotEmpty(req.getOrgCode())) { OrgDto org=new OrgDto();
setNewCode = req.getOrgCode().replaceAll("0+$", ""); BeanPlusUtil.copyProperties(p, org);
} else { orgs.add(org);
setNewCode = ""; });
} return orgs;
wrapper.eq(ObjectUtil.isNotEmpty(req.getIsDepartment()), PubOrg::getIsDepartment, req.getIsDepartment());
wrapper.eq(PubOrg::getStatusFlag, 1);
wrapper.likeRight(ObjectUtil.isNotEmpty(req.getOrgCode()), PubOrg::getOrgCode, setNewCode);
List<PubOrg> orgList = this.list(wrapper);
// 创建一个 Map 来存储机构 ID 和对应的 DTO 对象
Map<String, OrgTreeDto> orgDtoMap = new HashMap<>();
// 创建一个 Map 来存储父类的 parentid 和对应的父类节点
Map<String, List<OrgTreeDto>> parentDtoMap = new HashMap<>();
// 第一轮遍历:创建 OrgTreeDto 对象并将其加入到 Map 中
for (PubOrg org : orgList) {
OrgTreeDto orgDTO = new OrgTreeDto();
BeanPlusUtil.copyProperties(org, orgDTO);
orgDTO.setName(org.getDName());
orgDTO.setCode(org.getOrgCode());
orgDTO.setType(org.getOrgType());
orgDtoMap.put(org.getOrgId().toString(), orgDTO);
// 将根节点添加到 OrgDTOList 中
if (org.getOrgId().toString().equals(selfCode)) {
orgDTOList.add(orgDTO);
}
// 将当前节点添加到 parentDtoMap 中,以便后续节点连接
String parentId = org.getOrgParentId().toString();
if (!parentDtoMap.containsKey(parentId)) {
parentDtoMap.put(parentId, new ArrayList<>());
}
parentDtoMap.get(parentId).add(orgDTO);
}
// 第二轮遍历:将子节点连接到父节点
for (PubOrg org : orgList) {
String parentId = org.getOrgParentId().toString();
OrgTreeDto orgDTO = orgDtoMap.get(org.getOrgId().toString());
// 如果找到传入的ID对应的节点,则开始添加子节点
if (org.getOrgId().toString().equals(selfCode)) {
addChildToOrgDTO(orgDTO, orgDtoMap, parentDtoMap);
}
}
return orgDTOList;
} }
private void addChildToOrgDTO(OrgTreeDto parentOrgDTO, Map<String, OrgTreeDto> orgDtoMap, Map<String, List<OrgTreeDto>> parentDtoMap) {
String parentId = parentOrgDTO.getOrgId().toString();
List<OrgTreeDto> children = parentDtoMap.get(parentId);
if (children != null) {
for (OrgTreeDto child : children) {
parentOrgDTO.addChild(child);
addChildToOrgDTO(child, orgDtoMap, parentDtoMap);
}
}
}
private LambdaQueryWrapper<PubOrg> createWrapper(QueryOrgReq req) { private LambdaQueryWrapper<PubOrg> createWrapper(QueryOrgReq req) {
LambdaQueryWrapper<PubOrg> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PubOrg> wrapper = new LambdaQueryWrapper<>();
...@@ -404,7 +352,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -404,7 +352,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
wrapper.eq(ObjectUtil.isNotEmpty(req.getIsDepartment()), PubOrg::getIsDepartment, req.getIsDepartment()); wrapper.eq(ObjectUtil.isNotEmpty(req.getIsDepartment()), PubOrg::getIsDepartment, req.getIsDepartment());
//根据业务编码查询 //根据业务编码查询
wrapper.eq(ObjectUtil.isNotEmpty(req.getLevel()), PubOrg::getLevelFlag, req.getLevel()); wrapper.eq(ObjectUtil.isNotEmpty(req.getLevel()), PubOrg::getLevelFlag, req.getLevel());
wrapper.eq(ObjectUtil.isNotEmpty(req.getParentId()), PubOrg::getOrgParentId,Long.parseLong(req.getParentId()) ); wrapper.eq(ObjectUtil.isNotNull(req.getParentId()), PubOrg::getOrgParentId,req.getParentId() );
wrapper.eq(ObjectUtil.isNotEmpty(req.getOrgCode()), PubOrg::getOrgCode, req.getOrgCode()); wrapper.eq(ObjectUtil.isNotEmpty(req.getOrgCode()), PubOrg::getOrgCode, req.getOrgCode());
......
...@@ -109,10 +109,13 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i ...@@ -109,10 +109,13 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
if (ObjectUtil.isEmpty(req)) { if (ObjectUtil.isEmpty(req)) {
return wrapper; return wrapper;
} }
//根据供应商短码查询查询
wrapper.like(ObjectUtil.isNotEmpty(req.getCode()), Supplier::getCode, req.getCode()); wrapper.like(ObjectUtil.isNotEmpty(req.getCode()), Supplier::getCode, req.getCode());
//根据供应商短码查询查询
wrapper.like(ObjectUtil.isNotEmpty(req.getId()), Supplier::getId, req.getId());
//供应商名称模糊查询
wrapper.like(ObjectUtil.isNotEmpty(req.getName()), Supplier::getName, req.getName());
//供应商名称模糊查询 //供应商名称模糊查询
wrapper.eq(ObjectUtil.isNotEmpty(req.getName()), Supplier::getName, req.getName()); wrapper.like(ObjectUtil.isNotEmpty(req.getShortName()), Supplier::getShortName, req.getShortName());
//根据创建时间降序 //根据创建时间降序
wrapper.orderByDesc(Supplier::getCreateTime); wrapper.orderByDesc(Supplier::getCreateTime);
return wrapper; return wrapper;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论