Commit 9c718f2d authored by zhangyingbin's avatar zhangyingbin

新增根据资源id获取资源的附件信息接口,修改管材列表接口

parent f49531f2
package com.yeejoin.amos.boot.module.ugp.api.dto;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 材料信息表
......@@ -69,4 +71,6 @@ public class MaterialDto extends BaseDto {
@ApiModelProperty(value = "项目id")
private Long projectId;
private List<JSONObject> files;
}
......@@ -151,7 +151,7 @@ public class MaterialController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping( value = "/pageOutList")
@ApiOperation(httpMethod = "GET",value = "材料信息表分页查询", notes = "材料信息表分页查询")
public ResponseModel<IPage<Material>> queryPage( int current, int size, MaterialDto material) {
public ResponseModel<IPage<MaterialDto>> queryPage( int current, int size, MaterialDto material) {
IPage<Material> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
......@@ -168,7 +168,7 @@ public class MaterialController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping( value = "/pageInList")
@ApiOperation(httpMethod = "GET",value = "材料信息表分页查询", notes = "材料信息表分页查询")
public ResponseModel<IPage<Material>> queryMaterialPage( int current, int size, MaterialDto material) {
public ResponseModel<IPage<MaterialDto>> queryMaterialPage( int current, int size, MaterialDto material) {
IPage<Material> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
......@@ -20,9 +21,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.yeejoin.amos.boot.module.ugp.biz.controller.ProjectController;
......@@ -111,4 +110,37 @@ public class AttachmentServiceImpl extends BaseService<AttachmentDto,Attachment,
}
public List<JSONObject> getFilesBySourceId(Long sourceId){
LambdaQueryWrapper<Attachment> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Attachment :: getSourceId,sourceId );
List<Attachment> attachmentList = this.list(wrapper);
Iterator<Attachment> iterator = attachmentList.iterator();
List<JSONObject> jsonList = new ArrayList<>();
while (iterator.hasNext()) {
Attachment attachment = iterator.next();
String info = attachment.getInfo();
JSONArray jsonArray;
if(!ValidationUtil.isEmpty(info)){
try {
jsonArray = JSON.parseArray(info);
} catch (Exception e) {
continue;
}
if(!ValidationUtil.isEmpty(jsonArray)){
for(Object object:jsonArray){
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(object));
JSONArray ja = jo.getJSONArray("info");
if(!ValidationUtil.isEmpty(ja)){
for (Object o : ja) {
JSONObject jot = JSONObject.parseObject(JSON.toJSONString(o));
jsonList.add(jot);
}
}
}
}
}
}
return jsonList;
}
}
\ No newline at end of file
......@@ -62,6 +62,9 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
@Autowired
ProjectResourceServiceImpl projectResourceServiceImpl;
@Autowired
AttachmentServiceImpl attachmentService;
/**
* 分页查询
*/
......@@ -82,7 +85,7 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
/**
* 提交资料 获取管材列表 分页查询 projectId关联的资源
*/
public IPage<Material> queryOutPage(IPage<Material> page, MaterialDto material) {
public IPage<MaterialDto> queryOutPage(IPage<Material> page, MaterialDto material) {
LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>();
List materialIds = new ArrayList<>();
LambdaQueryWrapper<ProjectResource> resourceWrapper = new LambdaQueryWrapper<>();
......@@ -100,14 +103,27 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
}
getWrapper(wrapper,material);
wrapper.in(Material::getCompanyId,getCompanyIds());
return this.page(page,wrapper);
page = this.page(page,wrapper);
IPage<MaterialDto> dtoPage = new Page<>();
BeanUtils.copyProperties(page,dtoPage);
List<Material> materialList = page.getRecords();
List<MaterialDto> materialDtoList = new ArrayList<>();
if(!ValidationUtil.isEmpty(materialList)) {
for(Material mt : materialList) {
MaterialDto materialDto = new MaterialDto();
BeanUtils.copyProperties(mt,materialDto);
materialDto.setFiles(attachmentService.getFilesBySourceId(mt.getSequenceNbr()));
materialDtoList.add(materialDto);
}
}
dtoPage.setRecords(materialDtoList);
return dtoPage;
}
/**
* 提交资料 获取管材列表 分页查询 projectId关联的资源和空闲的资源
*/
public IPage<Material> queryInPage(IPage<Material> page, MaterialDto material) {
public IPage<MaterialDto> queryInPage(IPage<Material> page, MaterialDto material) {
LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>();
List materialIds = new ArrayList<>();
LambdaQueryWrapper<ProjectResource> resourceWrapper = new LambdaQueryWrapper<>();
......@@ -123,10 +139,24 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
getWrapper(wrapper,material);
wrapper.in(Material::getCompanyId,getCompanyIds());
return this.page(page,wrapper);
}
page = this.page(page,wrapper);
IPage<MaterialDto> dtoPage = new Page<>();
BeanUtils.copyProperties(page,dtoPage);
List<Material> materialList = page.getRecords();
List<MaterialDto> materialDtoList = new ArrayList<>();
if(!ValidationUtil.isEmpty(materialList)) {
for(Material mt : materialList) {
MaterialDto materialDto = new MaterialDto();
BeanUtils.copyProperties(mt,materialDto);
materialDto.setFiles(attachmentService.getFilesBySourceId(mt.getSequenceNbr()));
materialDtoList.add(materialDto);
}
}
dtoPage.setRecords(materialDtoList);
return dtoPage;
}
public void getWrapper(LambdaQueryWrapper<Material> wrapper,MaterialDto material){
if(!ValidationUtil.isEmpty(material.getName())){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment