采购需求添加绑定物料
This commit is contained in:
@@ -45,6 +45,10 @@ public class OaRequirements extends BaseEntity {
|
||||
* 挂接项目 ID,可选
|
||||
*/
|
||||
private Long projectId;
|
||||
/**
|
||||
* 关联物料 ID CSV -> sys_oa_warehouse.id,可选
|
||||
*/
|
||||
private String materialIds;
|
||||
/**
|
||||
* 需求描述
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,11 @@ public class OaRequirementsBo extends BaseEntity {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 关联物料 ID CSV,多个物料用逗号分隔
|
||||
*/
|
||||
private String materialIds;
|
||||
|
||||
/**
|
||||
* 需求描述
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,22 @@ public class OaRequirementsVo extends BaseEntity {
|
||||
private String ownerNickName;
|
||||
private String projectName;
|
||||
|
||||
/** 关联物料 ID CSV */
|
||||
private String materialIds;
|
||||
/** 关联物料明细(service 层 enrich,列表/详情都返回) */
|
||||
private java.util.List<MaterialItem> materials;
|
||||
|
||||
@Data
|
||||
public static class MaterialItem implements java.io.Serializable {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String model;
|
||||
private String unit;
|
||||
private Long inventory;
|
||||
private String brand;
|
||||
private String specifications;
|
||||
}
|
||||
|
||||
/** 附件文件列表(已联查 sys_oss,每项形如 "<ossId>|<originalName>|<url>",逗号分隔) */
|
||||
private String accessoryFiles;
|
||||
|
||||
|
||||
@@ -15,13 +15,19 @@ import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.OaRequirementsBo;
|
||||
import com.ruoyi.oa.domain.vo.OaRequirementsVo;
|
||||
import com.ruoyi.oa.domain.OaRequirements;
|
||||
import com.ruoyi.oa.domain.SysOaWarehouse;
|
||||
import com.ruoyi.oa.mapper.OaRequirementsMapper;
|
||||
import com.ruoyi.oa.mapper.SysOaWarehouseMapper;
|
||||
import com.ruoyi.oa.service.IOaRequirementsService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* OA 需求Service业务层处理
|
||||
@@ -37,12 +43,63 @@ public class OaRequirementsServiceImpl implements IOaRequirementsService {
|
||||
|
||||
private final OaWarehouseAuditService auditService;
|
||||
|
||||
private final SysOaWarehouseMapper warehouseMapper;
|
||||
|
||||
/**
|
||||
* 查询OA 需求
|
||||
*/
|
||||
@Override
|
||||
public OaRequirementsVo queryById(Long requirementId){
|
||||
return baseMapper.selectVoById(requirementId);
|
||||
OaRequirementsVo vo = baseMapper.selectVoById(requirementId);
|
||||
enrichMaterials(Collections.singletonList(vo));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/** 根据 material_ids(CSV)批量补全物料明细到 VO.materials */
|
||||
private void enrichMaterials(List<OaRequirementsVo> list) {
|
||||
if (list == null || list.isEmpty()) return;
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (OaRequirementsVo v : list) {
|
||||
if (v == null) continue;
|
||||
for (Long id : parseCsv(v.getMaterialIds())) ids.add(id);
|
||||
}
|
||||
if (ids.isEmpty()) return;
|
||||
List<SysOaWarehouse> wList = warehouseMapper.selectList(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<SysOaWarehouse>()
|
||||
.in("id", ids));
|
||||
Map<Long, SysOaWarehouse> wMap = wList.stream()
|
||||
.collect(Collectors.toMap(SysOaWarehouse::getId, w -> w, (a, b) -> a));
|
||||
for (OaRequirementsVo v : list) {
|
||||
if (v == null) continue;
|
||||
List<Long> mids = parseCsv(v.getMaterialIds());
|
||||
if (mids.isEmpty()) continue;
|
||||
List<OaRequirementsVo.MaterialItem> items = new ArrayList<>();
|
||||
for (Long id : mids) {
|
||||
SysOaWarehouse w = wMap.get(id);
|
||||
if (w == null) continue;
|
||||
OaRequirementsVo.MaterialItem it = new OaRequirementsVo.MaterialItem();
|
||||
it.setId(w.getId());
|
||||
it.setName(w.getName());
|
||||
it.setModel(w.getModel());
|
||||
it.setUnit(w.getUnit());
|
||||
it.setInventory(w.getInventory());
|
||||
it.setBrand(w.getBrand());
|
||||
it.setSpecifications(w.getSpecifications());
|
||||
items.add(it);
|
||||
}
|
||||
v.setMaterials(items);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Long> parseCsv(String csv) {
|
||||
if (csv == null || csv.isEmpty()) return Collections.emptyList();
|
||||
List<Long> r = new ArrayList<>();
|
||||
for (String s : csv.split(",")) {
|
||||
String t = s.trim();
|
||||
if (t.isEmpty()) continue;
|
||||
try { r.add(Long.parseLong(t)); } catch (NumberFormatException ignored) {}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +109,7 @@ public class OaRequirementsServiceImpl implements IOaRequirementsService {
|
||||
public TableDataInfo<OaRequirementsVo> queryPageList(OaRequirementsBo bo, PageQuery pageQuery) {
|
||||
QueryWrapper<OaRequirements> lqw = buildQueryWrapper(bo);
|
||||
Page<OaRequirementsVo> result = baseMapper.selectVoListPage(pageQuery.build(), lqw);
|
||||
enrichMaterials(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@@ -61,7 +119,9 @@ public class OaRequirementsServiceImpl implements IOaRequirementsService {
|
||||
@Override
|
||||
public List<OaRequirementsVo> queryList(OaRequirementsBo bo) {
|
||||
QueryWrapper<OaRequirements> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoListForExport(lqw);
|
||||
List<OaRequirementsVo> list = baseMapper.selectVoListForExport(lqw);
|
||||
enrichMaterials(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
private QueryWrapper<OaRequirements> buildQueryWrapper(OaRequirementsBo bo) {
|
||||
|
||||
@@ -68,6 +68,8 @@ public class SysOaWarehouseServiceImpl implements ISysOaWarehouseService {
|
||||
.like("sow.brand", bo.getName())
|
||||
.or()
|
||||
.like("sow.model", bo.getName())
|
||||
.or()
|
||||
.like("sow.specifications", bo.getName())
|
||||
)
|
||||
.eq(StringUtils.isNotBlank(bo.getModel()), "sow.model", bo.getModel())
|
||||
.eq(StringUtils.isNotBlank(bo.getBrand()), "sow.brand", bo.getBrand());
|
||||
|
||||
Reference in New Issue
Block a user