Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
99a945e33f
|
@ -1,5 +1,7 @@
|
|||
package io.renren.modules.fuse.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.renren.common.annotation.LogOperation;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.page.PageData;
|
||||
|
@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +32,7 @@ import java.util.Map;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("fuse")
|
||||
@Api(tags="融合服务")
|
||||
@Api(tags = "融合服务")
|
||||
public class FuseController {
|
||||
|
||||
@Autowired
|
||||
|
@ -38,35 +41,36 @@ public class FuseController {
|
|||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "name", value = "融合服务名称", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType="int"),
|
||||
@ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType="String")
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段,可选值(create_date、update_date、collectCount)", required = true, paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.ORDER, required = true, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "name", value = "融合服务名称", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int"),
|
||||
@ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType = "String")
|
||||
})
|
||||
public Result<PageData<TbFuseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
public Result<PageData<TbFuseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
PageData<TbFuseDTO> page = tbFuseService.page(params);
|
||||
return new Result<PageData<TbFuseDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("信息")
|
||||
public Result<TbFuseDTO> get(@PathVariable("id") Long id){
|
||||
@LogOperation("信息")
|
||||
public Result<TbFuseDTO> get(@PathVariable("id") Long id) {
|
||||
return new Result<TbFuseDTO>().ok(tbFuseService.getFuseById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("保存")
|
||||
@LogOperation("保存")
|
||||
public Result save(@RequestBody TbFuseDTO dto){
|
||||
public Result save(@RequestBody TbFuseDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
return new Result().ok(tbFuseService.addFuse(dto));
|
||||
|
@ -75,16 +79,17 @@ public class FuseController {
|
|||
@PutMapping
|
||||
@ApiOperation("修改")
|
||||
@LogOperation("修改")
|
||||
public Result update(@RequestBody TbFuseDTO dto){
|
||||
public Result update(@RequestBody TbFuseDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
return new Result().ok(tbFuseService.updateFuse(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
@LogOperation("删除")
|
||||
public Result delete(@RequestBody Long id){
|
||||
return new Result().ok(tbFuseService.deleteFuse(id));
|
||||
public Result delete(@RequestBody Long[] fuseIds) {
|
||||
Arrays.stream(fuseIds).forEach(id->tbFuseService.deleteFuse(id));
|
||||
return new Result();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package io.renren.modules.fuse.dao;
|
||||
|
||||
import io.renren.common.dao.BaseDao;
|
||||
import io.renren.modules.fuse.dto.TbFuseDTO;
|
||||
import io.renren.modules.fuse.entity.TbFuseEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Auther:lizhicheng2@hisense.com
|
||||
* @date:2022/6/30
|
||||
|
@ -12,4 +16,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface TbFuseDao extends BaseDao<TbFuseEntity> {
|
||||
|
||||
List<TbFuseDTO> getFuseDTOList(Map params);
|
||||
|
||||
List<Map<String, Object>> selectGroupByDeptId();
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ public class TbFuseDTO {
|
|||
private Long updater;
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateDate;
|
||||
@ApiModelProperty(value = "收藏标志")
|
||||
private String isCollect;
|
||||
@ApiModelProperty(value = "收藏量")
|
||||
private Integer collectCount;
|
||||
@ApiModelProperty(value = "资源融合关系")
|
||||
private List<TbFuseResourceDTO> fuseResourceList;
|
||||
@ApiModelProperty(value = "融合资源属性")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.renren.modules.fuse.dto;
|
||||
|
||||
import io.renren.modules.resource.dto.ResourceDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -22,5 +23,7 @@ public class TbFuseResourceDTO {
|
|||
private Long resourceId;
|
||||
@ApiModelProperty(value = "资源挂载顺序")
|
||||
private String sequence;
|
||||
@ApiModelProperty(value = "资源")
|
||||
private ResourceDTO resource;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TbFuseEntity extends BaseEntity {
|
|||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long deptId;
|
||||
/**
|
||||
* 部门联系人
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.renren.modules.fuse.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.renren.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
|
|
@ -21,4 +21,6 @@ public interface TbFuseService extends CrudService<TbFuseEntity, TbFuseDTO> {
|
|||
|
||||
Integer deleteFuse(Long id);
|
||||
|
||||
Integer count(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package io.renren.modules.fuse.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.service.impl.CrudServiceImpl;
|
||||
import io.renren.modules.fuse.dao.TbFuseAttrDao;
|
||||
|
@ -16,7 +16,10 @@ import io.renren.modules.fuse.entity.TbFuseAttrEntity;
|
|||
import io.renren.modules.fuse.entity.TbFuseEntity;
|
||||
import io.renren.modules.fuse.entity.TbFuseResourceEntity;
|
||||
import io.renren.modules.fuse.service.TbFuseService;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.renren.modules.resource.service.impl.ResourceServiceImpl;
|
||||
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
@ -24,8 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -44,6 +46,10 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
private TbFuseResourceDao fuseResourceDao;
|
||||
@Autowired
|
||||
private TbFuseAttrDao fuseAttrDao;
|
||||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
@Autowired
|
||||
private ResourceCollectionDao resourceCollectionDao;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<TbFuseEntity> getWrapper(Map<String, Object> params) {
|
||||
|
@ -95,31 +101,57 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
}
|
||||
|
||||
@Override
|
||||
public PageData<TbFuseDTO> page(Map<String, Object> params){
|
||||
IPage<TbFuseEntity> page = baseDao.selectPage(
|
||||
getPage(params, null, false),
|
||||
getWrapper(params)
|
||||
);
|
||||
List<TbFuseDTO> result=page.getRecords().stream().map(entity->{
|
||||
TbFuseDTO dto=new TbFuseDTO();
|
||||
BeanUtils.copyProperties(entity, dto);
|
||||
public PageData<TbFuseDTO> page(Map<String, Object> params) {
|
||||
long curPage = 1;
|
||||
long limit = 10;
|
||||
if (params.get(Constant.PAGE) != null) {
|
||||
curPage = Long.parseLong((String) params.get(Constant.PAGE));
|
||||
}
|
||||
if (params.get(Constant.LIMIT) != null) {
|
||||
limit = Long.parseLong((String) params.get(Constant.LIMIT));
|
||||
}
|
||||
params.put("userId", SecurityUser.getUserId());
|
||||
List<TbFuseDTO> dtoList = baseDao.getFuseDTOList(params);
|
||||
dtoList.forEach(dto -> {
|
||||
dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId()));
|
||||
dto.setFuseAttrList(getAttrByFuseId(dto.getId()));
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
return new PageData(result, page.getTotal());
|
||||
});
|
||||
List<TbFuseDTO> result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList());
|
||||
return new PageData(result, dtoList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer count(Map<String, Object> params) {
|
||||
if (params != null) {
|
||||
return baseDao.selectCount(getWrapper(params));
|
||||
} else {
|
||||
return baseDao.selectCount(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbFuseDTO getFuseById(Long id) {
|
||||
TbFuseEntity fuseEntity = fuseDao.selectById(id);
|
||||
if(fuseEntity==null){
|
||||
return null;
|
||||
}
|
||||
TbFuseDTO fuseDTO = new TbFuseDTO();
|
||||
BeanUtils.copyProperties(fuseEntity, fuseDTO);
|
||||
fuseDTO.setFuseAttrList(getAttrByFuseId(id));
|
||||
fuseDTO.setFuseResourceList(getFuseResourceByFuseId(id));
|
||||
setCollection(fuseDTO);
|
||||
return fuseDTO;
|
||||
}
|
||||
|
||||
private void setCollection(TbFuseDTO dto) {
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("del_flag", "0");
|
||||
wrapper.eq("resource_id", dto.getId());
|
||||
dto.setCollectCount(resourceCollectionDao.selectCount(wrapper));
|
||||
wrapper.eq("user_id", SecurityUser.getUserId());
|
||||
dto.setIsCollect(resourceCollectionDao.selectCount(wrapper) > 0 ? "true" : "false");
|
||||
}
|
||||
|
||||
private List<TbFuseAttrDTO> getAttrByFuseId(Long fuseId) {
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("fuse_id", fuseId);
|
||||
|
@ -138,6 +170,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
return list.stream().map(attr -> {
|
||||
TbFuseResourceDTO dto = new TbFuseResourceDTO();
|
||||
BeanUtils.copyProperties(attr, dto);
|
||||
dto.setResource(resourceService.get(dto.getResourceId()));
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
@ -147,18 +180,18 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
public Integer addFuse(TbFuseDTO dto) {
|
||||
TbFuseEntity fuseEntity = new TbFuseEntity();
|
||||
BeanUtils.copyProperties(dto, fuseEntity);
|
||||
int result=fuseDao.insert(fuseEntity);
|
||||
dto.getFuseResourceList().forEach(fuseResourceDTO->{
|
||||
int result = fuseDao.insert(fuseEntity);
|
||||
dto.getFuseResourceList().forEach(fuseResourceDTO -> {
|
||||
fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO));
|
||||
fuseResourceDTO.setFuseId(fuseEntity.getId());
|
||||
TbFuseResourceEntity entity=new TbFuseResourceEntity();
|
||||
TbFuseResourceEntity entity = new TbFuseResourceEntity();
|
||||
BeanUtils.copyProperties(fuseResourceDTO, entity);
|
||||
fuseResourceDao.insert(entity);
|
||||
});
|
||||
dto.getFuseAttrList().forEach(fuseAttrDTO -> {
|
||||
fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO));
|
||||
fuseAttrDTO.setFuseId(fuseEntity.getId());
|
||||
TbFuseAttrEntity entity=new TbFuseAttrEntity();
|
||||
TbFuseAttrEntity entity = new TbFuseAttrEntity();
|
||||
BeanUtils.copyProperties(fuseAttrDTO, entity);
|
||||
fuseAttrDao.insert(entity);
|
||||
});
|
||||
|
@ -171,10 +204,10 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
TbFuseEntity fuseEntity = new TbFuseEntity();
|
||||
BeanUtils.copyProperties(dto, fuseEntity);
|
||||
fuseResourceDao.deleteByFuseId(fuseEntity.getId());
|
||||
dto.getFuseResourceList().forEach(fuseResourceDTO->{
|
||||
dto.getFuseResourceList().forEach(fuseResourceDTO -> {
|
||||
fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO));
|
||||
fuseResourceDTO.setFuseId(fuseEntity.getId());
|
||||
TbFuseResourceEntity entity=new TbFuseResourceEntity();
|
||||
TbFuseResourceEntity entity = new TbFuseResourceEntity();
|
||||
BeanUtils.copyProperties(fuseResourceDTO, entity);
|
||||
fuseResourceDao.insert(entity);
|
||||
});
|
||||
|
@ -182,7 +215,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
dto.getFuseAttrList().forEach(fuseAttrDTO -> {
|
||||
fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO));
|
||||
fuseAttrDTO.setFuseId(fuseEntity.getId());
|
||||
TbFuseAttrEntity entity=new TbFuseAttrEntity();
|
||||
TbFuseAttrEntity entity = new TbFuseAttrEntity();
|
||||
BeanUtils.copyProperties(fuseAttrDTO, entity);
|
||||
fuseAttrDao.insert(entity);
|
||||
});
|
||||
|
@ -194,6 +227,9 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
|
|||
public Integer deleteFuse(Long id) {
|
||||
fuseResourceDao.deleteByFuseId(id);
|
||||
fuseAttrDao.deleteByFuseId(id);
|
||||
resourceCollectionDao.delete4Resource(new ArrayList<Long>() {{
|
||||
this.add(id);
|
||||
}});
|
||||
return fuseDao.deleteById(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -518,13 +518,11 @@ public class ResourceController {
|
|||
}
|
||||
|
||||
@GetMapping("/getApplyByDept")
|
||||
@ApiOperation("获取当前登录用户所在部门申请的资源")
|
||||
@LogOperation("获取当前登录用户所在部门申请的资源")
|
||||
@ApiOperation("获取当前登录用户所在部门申请的资源-按照申请次数排名")
|
||||
@LogOperation("获取当前登录用户所在部门申请的资源-按照申请次数排名")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int")
|
||||
})
|
||||
public Result getApplyByDept(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
return new Result().ok(resourceService.getApplyByDept(params));
|
||||
|
@ -554,4 +552,11 @@ public class ResourceController {
|
|||
public Result selectInfrastructureList() {
|
||||
return new Result().ok(resourceService.selectInfrastructureList());
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("能力查询")
|
||||
@LogOperation("能力查询")
|
||||
public Result list(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
return new Result<>().ok(resourceService.list(params));
|
||||
}
|
||||
}
|
|
@ -164,4 +164,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
Long selectDayAvg(@Param("days") Long days);
|
||||
|
||||
Integer selectDayMax();
|
||||
|
||||
List<ResourceDTO> selectUsersApplyAndCount(@Param("userIds") List<Long> userIds);
|
||||
}
|
|
@ -1617,32 +1617,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
limit = Integer.parseInt((String) params.get(Constant.LIMIT));
|
||||
}
|
||||
List<SysUserDTO> sysUserList = sysUserService.list(new HashMap());
|
||||
List<HistoricProcessInstance> list = new ArrayList<>();
|
||||
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
|
||||
query.orderByProcessInstanceStartTime().desc();
|
||||
for (SysUserDTO user : sysUserList) {
|
||||
query.startedBy(user.getId().toString());
|
||||
list.addAll(query.list());
|
||||
List<ResourceDTO> result=resourceDao.selectUsersApplyAndCount(sysUserList.stream().map(dto->dto.getId()).collect(Collectors.toList()));
|
||||
int j = Math.min(curPage * limit, result.size());
|
||||
ArrayList<ResourceDTO> recordLists = new ArrayList<>();
|
||||
for (int i = (curPage - 1) * limit; i < j; i++) {
|
||||
recordLists.add(result.get(i));
|
||||
}
|
||||
boolean isAsc = false;
|
||||
if (params.get(Constant.ORDER) != null && "asc".equals(params.get(Constant.ORDER))) {
|
||||
isAsc = true;
|
||||
}
|
||||
String orderColumn = params.get(Constant.ORDER_FIELD) == null ? "create_date" : (String) params.get(Constant.ORDER_FIELD);
|
||||
List<Long> resourceIds = getSourceIdsByProcess(list);
|
||||
IPage<ResourceEntity> page = new Page<>(curPage, limit);
|
||||
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (!resourceIds.isEmpty()) {
|
||||
queryWrapper.in("id", resourceIds);
|
||||
}
|
||||
queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderBy(true, isAsc, orderColumn);
|
||||
List<ResourceDTO> dtoList = ConvertUtils.sourceToTarget(Optional.ofNullable(resourceDao.selectPage(page, queryWrapper).getRecords()).orElse(new ArrayList<>()), ResourceDTO.class);
|
||||
dtoList.forEach(temp -> {
|
||||
Map p = new HashMap();
|
||||
p.put("resource_id", temp.getId());
|
||||
temp.setApplyCount(String.valueOf(tAbilityApplicationService.list(p).size()));
|
||||
});
|
||||
return new PageData<>(dtoList, dtoList.size());
|
||||
return new PageData<>(recordLists, result.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,9 +20,9 @@ public interface ResourceCollectionDao extends BaseDao<ResourceCollectionEntity>
|
|||
|
||||
Integer deleteByIds(@Param("ids") Long[] ids);
|
||||
|
||||
List<ResourceCollectionDTO> selectPageWithResource(@Param("params") Map<String, Object> params,
|
||||
@Param("pageNum") Integer pageNum,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
List<ResourceCollectionDTO> selectWithResource(@Param("params") Map<String, Object> params);
|
||||
|
||||
List<ResourceCollectionDTO> selectWithFuse(@Param("params") Map<String, Object> params);
|
||||
|
||||
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.renren.modules.resourceCollection.dto;
|
||||
|
||||
import io.renren.modules.fuse.dto.TbFuseDTO;
|
||||
import io.renren.modules.resource.dto.ResourceDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -47,4 +48,6 @@ public class ResourceCollectionDTO implements Serializable {
|
|||
|
||||
@ApiModelProperty(value = "资源信息")
|
||||
private ResourceDTO resourceDTO;
|
||||
@ApiModelProperty(value = "融合服务信息")
|
||||
private TbFuseDTO fuseDTO;
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.renren.common.service.impl.CrudServiceImpl;
|
||||
import io.renren.modules.fuse.service.TbFuseService;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
|
||||
import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO;
|
||||
|
@ -16,6 +17,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -37,6 +39,8 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl<ResourceColle
|
|||
private ResourceService resourceService;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
@Autowired
|
||||
private TbFuseService fuseService;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<ResourceCollectionEntity> getWrapper(Map<String, Object> params) {
|
||||
|
@ -51,11 +55,27 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl<ResourceColle
|
|||
int pageSize = Integer.parseInt(params.get("pageSize").toString());
|
||||
Page<ResourceCollectionDTO> page = new Page(pageNum, pageSize);
|
||||
params.put("userId", user.getId());
|
||||
List<ResourceCollectionDTO> resourceCollectionDTOS = resourceCollectionDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize);
|
||||
List<ResourceCollectionDTO> result=new ArrayList<>();
|
||||
List<ResourceCollectionDTO> resourceCollectionDTOS = resourceCollectionDao.selectWithResource(params);
|
||||
resourceCollectionDTOS.forEach(item -> item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId())));
|
||||
List<ResourceCollectionDTO> resourceCollectionDTOSs = resourceCollectionDao.selectPageWithResource(params, 0, 100000);
|
||||
page.setRecords(resourceCollectionDTOS);
|
||||
page.setTotal(resourceCollectionDTOSs.size());
|
||||
result.addAll(resourceCollectionDTOS);
|
||||
if(params.get("type") == null || "".equals(params.get("type"))){
|
||||
List<ResourceCollectionDTO> fuseCollectionDTOS = resourceCollectionDao.selectWithFuse(params);
|
||||
fuseCollectionDTOS.forEach(item -> item.setFuseDTO(fuseService.getFuseById(item.getResourceId())));
|
||||
result.addAll(fuseCollectionDTOS);
|
||||
}
|
||||
int j = Math.min(pageNum * pageSize, result.size());
|
||||
if (result.isEmpty()) {
|
||||
page.setRecords(null);
|
||||
page.setTotal(0);
|
||||
} else {
|
||||
ArrayList<ResourceCollectionDTO> recordLists = new ArrayList<>();
|
||||
for (int i = (pageNum - 1) * pageSize; i < j; i++) {
|
||||
recordLists.add(result.get(i));
|
||||
}
|
||||
page.setRecords(recordLists);
|
||||
page.setTotal(result.size());
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,84 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="io.renren.modules.fuse.dao.TbFuseDao">
|
||||
|
||||
<resultMap id="fuseDTO" type="io.renren.modules.fuse.dto.TbFuseDTO">
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="applicationArea" column="application_area"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="deptUser" column="dept_user"/>
|
||||
<result property="mobile" column="mobile"/>
|
||||
<result property="provider" column="provider"/>
|
||||
<result property="providerUser" column="provider_user"/>
|
||||
<result property="providerMobile" column="provider_mobile"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="createDate" column="create_date"/>
|
||||
<result property="updater" column="updater"/>
|
||||
<result property="updateDate" column="update_date"/>
|
||||
<result property="isCollect" column="isCollect"/>
|
||||
<result property="collectCount" column="collectCount"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getFuseDTOList" resultMap="fuseDTO">
|
||||
select tf.*, count(trc.id) as collectCount, if(sum(trc.user_id=#{userId})>0 , 'true', 'false') as isCollect
|
||||
from tb_fuse tf left join (select id, resource_Id, user_id from tb_resource_collection where 1=1 and del_flag=0) trc on tf.id=trc.resource_id
|
||||
where 1=1
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
and description like concat('%', #{description}, '%')
|
||||
</if>
|
||||
<if test="applicationArea != null and applicationArea != ''">
|
||||
and application_area like concat('%', #{applicationArea}, '%')
|
||||
</if>
|
||||
<if test="deptId != null and deptId != ''">
|
||||
and deptId = #{deptId}
|
||||
</if>
|
||||
<if test="deptUser != null and deptUser != ''">
|
||||
and dept_user like concat('%', #{deptUser}, '%')
|
||||
</if>
|
||||
<if test="mobile != null and mobile != ''">
|
||||
and mobile like concat('%', #{mobile}, '%')
|
||||
</if>
|
||||
<if test="provider != null and provider != ''">
|
||||
and provider like concat('%', #{provider}, '%')
|
||||
</if>
|
||||
<if test="providerUser != null and providerUser != ''">
|
||||
and provider_user like concat('%', #{providerUser}, '%')
|
||||
</if>
|
||||
<if test="providerMobile != null and providerMobile != ''">
|
||||
and provider_mobile like concat('%', #{providerMobile}, '%')
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
and creator = #{creator}
|
||||
</if>
|
||||
<if test="createDate != null and createDate != ''">
|
||||
and create_date #{createDate}
|
||||
</if>
|
||||
<if test="updater != null and updater != ''">
|
||||
and updater = #{updater}
|
||||
</if>
|
||||
<if test="updateDate != null and updateDate != ''">
|
||||
and updateDate #{updateDate}
|
||||
</if>
|
||||
group by tf.id
|
||||
ORDER BY ${orderField} ${orderType}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupByDeptId" resultType="java.util.Map">
|
||||
SELECT ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||
sd.NAME AS "deptName",
|
||||
count(tdr.id) AS "deptCount",
|
||||
sd.id AS "deptId",
|
||||
sr.name AS "districtName",
|
||||
sr.id AS "districtId"
|
||||
FROM sys_dept sd
|
||||
inner join tb_fuse tdr on sd.id=tdr.dept_id
|
||||
left join sys_region sr on sr.id=sd.district
|
||||
group by sd.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1336,10 +1336,13 @@
|
|||
</select>
|
||||
|
||||
<select id="selectDeptResourceByApplyNum" resultType="java.util.Map">
|
||||
SELECT count(taa.id) as count, tdr.name
|
||||
SELECT tdr.name, count(taa.id) as count
|
||||
FROM tb_data_resource tdr left join t_ability_application taa on tdr.id=taa.resource_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND tdr.del_flag = 0
|
||||
<if test="null != list">
|
||||
where tdr.dept_id in
|
||||
and tdr.dept_id in
|
||||
<foreach item="deptId" collection="list" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
|
@ -1347,6 +1350,21 @@
|
|||
group by tdr.id order by count desc
|
||||
</select>
|
||||
|
||||
<select id="selectUsersApplyAndCount" resultMap="resourceDTO">
|
||||
SELECT tdr.*, count(taa.id) as applyCount
|
||||
FROM tb_data_resource tdr left join t_ability_application taa on tdr.id=taa.resource_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND tdr.del_flag = 0
|
||||
<if test="null != userIds">
|
||||
and taa.user_id in
|
||||
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</if>
|
||||
group by tdr.id order by applyCount desc
|
||||
</select>
|
||||
|
||||
<select id="trafficDeptResource" resultType="java.util.Map">
|
||||
SELECT
|
||||
SUBSTR(create_date, 1, 10) AS "date",
|
||||
|
|
|
@ -53,12 +53,10 @@
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCollection.dto.ResourceCollectionDTO">
|
||||
<select id="selectWithResource" resultType="io.renren.modules.resourceCollection.dto.ResourceCollectionDTO">
|
||||
SELECT trc.*
|
||||
FROM tb_resource_collection trc
|
||||
<if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')">
|
||||
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag != 1
|
||||
</if>
|
||||
INNER JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag != 1
|
||||
WHERE 1 = 1
|
||||
AND trc.del_flag = 0
|
||||
AND user_id = #{params.userId}
|
||||
|
@ -69,7 +67,19 @@
|
|||
AND tdr.type = #{params.type}
|
||||
</if>
|
||||
ORDER BY trc.update_date DESC, trc.create_date DESC
|
||||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectWithFuse" resultType="io.renren.modules.resourceCollection.dto.ResourceCollectionDTO">
|
||||
SELECT trc.*
|
||||
FROM tb_resource_collection trc
|
||||
INNER JOIN tb_fuse tf ON trc.resource_id = tf.id
|
||||
WHERE 1 = 1
|
||||
AND trc.del_flag = 0
|
||||
AND user_id = #{params.userId}
|
||||
<if test="params.name != null and params.name != ''" >
|
||||
AND tf.name LIKE CONCAT('%',#{params.name},'%')
|
||||
</if>
|
||||
ORDER BY trc.update_date DESC, trc.create_date DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue