项目修改
parent
60d6a56a40
commit
0af33c15ac
|
|
@ -4,6 +4,8 @@ import com.njzscloud.common.core.utils.R;
|
|||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.dispose.cst.project.pojo.entity.ProjectEntity;
|
||||
import com.njzscloud.dispose.cst.project.pojo.param.ProjectQueryParam;
|
||||
import com.njzscloud.dispose.cst.project.pojo.result.ProjectDetailResult;
|
||||
import com.njzscloud.dispose.cst.project.service.ProjectService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -55,7 +57,7 @@ public class ProjectController {
|
|||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public R<ProjectEntity> detail(@RequestParam("id") Long id) {
|
||||
public R<ProjectDetailResult> detail(@RequestParam("id") Long id) {
|
||||
return R.success(projectService.detail(id));
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +65,8 @@ public class ProjectController {
|
|||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/paging")
|
||||
public R<PageResult<ProjectEntity>> paging(PageParam pageParam, ProjectEntity projectEntity) {
|
||||
return R.success(projectService.paging(pageParam, projectEntity));
|
||||
public R<PageResult<ProjectDetailResult>> paging(PageParam pageParam, ProjectQueryParam queryParam) {
|
||||
return R.success(projectService.paging(pageParam, queryParam));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njzscloud.dispose.cst.project.pojo.entity.ProjectEntity;
|
||||
import com.njzscloud.dispose.cst.project.pojo.result.ProjectDetailResult;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
@Mapper
|
||||
public interface ProjectMapper extends BaseMapper<ProjectEntity> {
|
||||
|
||||
Page<ProjectEntity> paging(Page<ProjectEntity> page, @Param("ew") QueryWrapper<ProjectEntity> ew);
|
||||
Page<ProjectDetailResult> paging(Page<ProjectEntity> page, @Param("ew") QueryWrapper<ProjectEntity> ew);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.njzscloud.dispose.cst.project.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njzscloud.dispose.common.pojo.entity.BaseEntity;
|
||||
import com.njzscloud.dispose.cst.customer.pojo.entity.CustomerEntity;
|
||||
import com.njzscloud.dispose.cst.org.pojo.entity.OrgEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
|
@ -38,48 +35,21 @@ public class ProjectEntity extends BaseEntity {
|
|||
*/
|
||||
private Long transCustomerId;
|
||||
|
||||
/**
|
||||
* 运输方客户信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private CustomerEntity transCustomerInfo;
|
||||
|
||||
/**
|
||||
* 运输方组织 Id
|
||||
*/
|
||||
private Long transOrgId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String transOrgName;
|
||||
|
||||
/**
|
||||
* 运输方组织信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private OrgEntity transOrgInfo;
|
||||
|
||||
/**
|
||||
* 产废方/购买方客户 Id
|
||||
*/
|
||||
private Long fringeCustomerId;
|
||||
|
||||
/**
|
||||
* 产废方/购买方客户信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private CustomerEntity fringeCustomerInfo;
|
||||
|
||||
/**
|
||||
* 产废方/购买方组织 Id
|
||||
*/
|
||||
private Long fringeOrgId;
|
||||
|
||||
/**
|
||||
* 产废方/购买方组织信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private OrgEntity fringeOrgInfo;
|
||||
|
||||
/**
|
||||
* 省;代码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.njzscloud.dispose.cst.project.pojo.param;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 项目分页查询入参
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ProjectQueryParam {
|
||||
|
||||
/**
|
||||
* 是否删除; 0-->未删除、1-->已删除
|
||||
* 作为查询条件时,默认按未删除(0)处理
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
/**
|
||||
* 项目名称(模糊查询)
|
||||
*/
|
||||
private String projectName;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
package com.njzscloud.dispose.cst.project.pojo.result;
|
||||
|
||||
import com.njzscloud.dispose.cst.customer.pojo.entity.CustomerEntity;
|
||||
import com.njzscloud.dispose.cst.org.pojo.entity.OrgEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 项目详情/列表返回结果
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class ProjectDetailResult {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 合同图片
|
||||
*/
|
||||
private String contractPicture;
|
||||
|
||||
/**
|
||||
* 运输方客户 Id
|
||||
*/
|
||||
private Long transCustomerId;
|
||||
|
||||
/**
|
||||
* 运输方客户信息
|
||||
*/
|
||||
private CustomerEntity transCustomerInfo;
|
||||
|
||||
/**
|
||||
* 运输方组织 Id
|
||||
*/
|
||||
private Long transOrgId;
|
||||
|
||||
/**
|
||||
* 运输方组织名称
|
||||
*/
|
||||
private String transOrgName;
|
||||
|
||||
/**
|
||||
* 运输方组织信息
|
||||
*/
|
||||
private OrgEntity transOrgInfo;
|
||||
|
||||
/**
|
||||
* 产废方/购买方客户 Id
|
||||
*/
|
||||
private Long fringeCustomerId;
|
||||
|
||||
/**
|
||||
* 产废方/购买方客户信息
|
||||
*/
|
||||
private CustomerEntity fringeCustomerInfo;
|
||||
|
||||
/**
|
||||
* 产废方/购买方组织 Id
|
||||
*/
|
||||
private Long fringeOrgId;
|
||||
|
||||
/**
|
||||
* 产废方/购买方组织信息
|
||||
*/
|
||||
private OrgEntity fringeOrgInfo;
|
||||
|
||||
/**
|
||||
* 省;代码
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市;代码
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区县;代码
|
||||
*/
|
||||
private String area;
|
||||
|
||||
/**
|
||||
* 乡镇街道;代码
|
||||
*/
|
||||
private String town;
|
||||
|
||||
/**
|
||||
* 省;名称
|
||||
*/
|
||||
private String provinceName;
|
||||
|
||||
/**
|
||||
* 市;名称
|
||||
*/
|
||||
private String cityName;
|
||||
|
||||
/**
|
||||
* 区县;名称
|
||||
*/
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 乡镇街道;名称
|
||||
*/
|
||||
private String townName;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lng;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
/**
|
||||
* 合同有效期
|
||||
*/
|
||||
private LocalDate contractStartDate;
|
||||
|
||||
/**
|
||||
* 合同有效期
|
||||
*/
|
||||
private LocalDate contractEndDate;
|
||||
|
||||
/**
|
||||
* 创建人 Id;sys_user.id
|
||||
*/
|
||||
private Long creatorId;
|
||||
|
||||
/**
|
||||
* 修改人 Id; sys_user.id
|
||||
*/
|
||||
private Long modifierId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
/**
|
||||
* 是否删除; 0-->未删除、1-->已删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.dispose.cst.project.pojo.entity.ProjectEntity;
|
||||
import com.njzscloud.dispose.cst.project.pojo.param.ProjectQueryParam;
|
||||
import com.njzscloud.dispose.cst.project.pojo.result.ProjectDetailResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,9 +21,9 @@ public interface ProjectService extends IService<ProjectEntity> {
|
|||
|
||||
void del(List<Long> ids);
|
||||
|
||||
ProjectEntity detail(Long id);
|
||||
ProjectDetailResult detail(Long id);
|
||||
|
||||
PageResult<ProjectEntity> paging(PageParam pageParam, ProjectEntity projectEntity);
|
||||
PageResult<ProjectDetailResult> paging(PageParam pageParam, ProjectQueryParam queryParam);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.njzscloud.dispose.cst.project.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
|
@ -14,6 +16,8 @@ import com.njzscloud.dispose.cst.org.pojo.entity.OrgEntity;
|
|||
import com.njzscloud.dispose.cst.org.service.OrgService;
|
||||
import com.njzscloud.dispose.cst.project.mapper.ProjectMapper;
|
||||
import com.njzscloud.dispose.cst.project.pojo.entity.ProjectEntity;
|
||||
import com.njzscloud.dispose.cst.project.pojo.param.ProjectQueryParam;
|
||||
import com.njzscloud.dispose.cst.project.pojo.result.ProjectDetailResult;
|
||||
import com.njzscloud.dispose.cst.project.service.ProjectService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -53,27 +57,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectEntity
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProjectEntity detail(Long id) {
|
||||
public ProjectDetailResult detail(Long id) {
|
||||
ProjectEntity detail = this.getById(id);
|
||||
if (detail != null) {
|
||||
fillCustomerAndOrgInfo(Collections.singletonList(detail));
|
||||
if (detail == null) {
|
||||
return null;
|
||||
}
|
||||
return detail;
|
||||
ProjectDetailResult result = BeanUtil.copyProperties(detail, ProjectDetailResult.class);
|
||||
fillCustomerAndOrgInfo(Collections.singletonList(result));
|
||||
// 使用 BeanUtil 直接复制属性
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProjectEntity> paging(PageParam pageParam, ProjectEntity projectEntity) {
|
||||
QueryWrapper<ProjectEntity> ew = Wrappers.<ProjectEntity>query().eq("p.deleted", 0);
|
||||
if (projectEntity != null) {
|
||||
String projectName = projectEntity.getProjectName();
|
||||
String transOrgName = projectEntity.getTransOrgName();
|
||||
ew.like(projectName != null, "p.project_name", projectName).like(transOrgName != null, "o.org_name", transOrgName);
|
||||
public PageResult<ProjectDetailResult> paging(PageParam pageParam, ProjectQueryParam queryParam) {
|
||||
if (queryParam == null) {
|
||||
queryParam = new ProjectQueryParam();
|
||||
}
|
||||
String projectName = queryParam.getProjectName();
|
||||
|
||||
// 直接调用自定义分页 SQL(项目名称 & 运输公司名称均为模糊查询)
|
||||
QueryWrapper<ProjectEntity> ew = Wrappers.<ProjectEntity>query()
|
||||
.eq("p.deleted", Boolean.FALSE)
|
||||
.like(StrUtil.isNotBlank(projectName), "p.project_name", projectName);
|
||||
|
||||
// 直接调用自定义分页 SQL
|
||||
Page<ProjectEntity> page = pageParam.toPage();
|
||||
page.addOrder(OrderItem.desc("p.create_time"));
|
||||
Page<ProjectEntity> paging = baseMapper.paging(page, ew);
|
||||
Page<ProjectDetailResult> paging = baseMapper.paging(page, ew);
|
||||
|
||||
if (CollUtil.isNotEmpty(paging.getRecords())) {
|
||||
fillCustomerAndOrgInfo(paging.getRecords());
|
||||
|
|
@ -85,12 +94,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectEntity
|
|||
/**
|
||||
* 批量填充运输方 / 产废方(购买方)的客户与组织信息
|
||||
*/
|
||||
private void fillCustomerAndOrgInfo(List<ProjectEntity> records) {
|
||||
private void fillCustomerAndOrgInfo(List<ProjectDetailResult> records) {
|
||||
// 收集所有需要的 ID
|
||||
Set<Long> transCustomerIds = records.stream().map(ProjectEntity::getTransCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> fringeCustomerIds = records.stream().map(ProjectEntity::getFringeCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> transOrgIds = records.stream().map(ProjectEntity::getTransOrgId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> fringeOrgIds = records.stream().map(ProjectEntity::getFringeOrgId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> transCustomerIds = records.stream().map(ProjectDetailResult::getTransCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> fringeCustomerIds = records.stream().map(ProjectDetailResult::getFringeCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> transOrgIds = records.stream().map(ProjectDetailResult::getTransOrgId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> fringeOrgIds = records.stream().map(ProjectDetailResult::getFringeOrgId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
|
||||
Set<Long> allCustomerIds = new HashSet<>(transCustomerIds);
|
||||
allCustomerIds.addAll(fringeCustomerIds);
|
||||
|
|
@ -107,7 +116,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectEntity
|
|||
orgMap = orgService.listByIds(allOrgIds).stream().collect(Collectors.toMap(OrgEntity::getId, it -> it));
|
||||
}
|
||||
|
||||
for (ProjectEntity item : records) {
|
||||
for (ProjectDetailResult item : records) {
|
||||
if (item.getTransCustomerId() != null) {
|
||||
item.setTransCustomerInfo(customerMap.get(item.getTransCustomerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njzscloud.dispose.cst.project.mapper.ProjectMapper">
|
||||
|
||||
<resultMap id="ProjectResultMap" type="com.njzscloud.dispose.cst.project.pojo.entity.ProjectEntity">
|
||||
<resultMap id="ProjectResultMap" type="com.njzscloud.dispose.cst.project.pojo.result.ProjectDetailResult">
|
||||
<id column="id" property="id"/>
|
||||
<result column="project_name" property="projectName"/>
|
||||
<result column="contract_picture" property="contractPicture"/>
|
||||
|
|
@ -43,11 +43,10 @@
|
|||
WHERE p.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 分页查询,支持项目名称模糊查询与运输公司名称模糊查询(直接表关联写法) -->
|
||||
<!-- 分页查询,支持项目名称模糊查询 -->
|
||||
<select id="paging" resultMap="ProjectResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM cst_project p
|
||||
LEFT JOIN cst_org o ON o.id = p.trans_org_id AND o.deleted = 0
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
${ew.customSqlSegment}
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue