Compare commits

..

2 Commits

Author SHA1 Message Date
mashuai fd650d2f3c Merge remote-tracking branch 'origin/master' 2025-09-23 20:12:43 +08:00
mashuai e83e88e68f 材料站优化 2025-09-23 20:12:32 +08:00
10 changed files with 646 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.clz.domain.TeamVo;
import com.bonus.material.clz.domain.machine.MaterialStorageDto;
import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo;
import com.bonus.material.clz.domain.vo.*;
import com.bonus.material.ma.domain.Machine;
@ -15,6 +16,7 @@ import com.bonus.material.clz.domain.machine.MaterialStorageInfo;
import com.bonus.material.clz.service.MaterialMachineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author ma_sh
@ -122,6 +125,27 @@ public class MaterialMachineController extends BaseController {
util.exportExcel(response, list, "综合查询--在库机具设备详情");
}
/**
* 导出站内库存在库设备详情
* @param bean
* @return
*/
@ApiOperation(value = "综合查询--导出站内库存在库设备详情")
@PostMapping("/exportStorageInfo")
public void exportStorageInfo(HttpServletResponse response, MaterialStorageInfo bean) {
List<MaterialStorageInfo> list = materialMachineService.getMaCodeList(bean);
// 如果list将MaterialStorageInfo转换为MaterialStorageDto
List<MaterialStorageDto> resultList = list.stream()
.map(item -> {
MaterialStorageDto dto = new MaterialStorageDto();
BeanUtils.copyProperties(item, dto);
return dto; // 必须返回转换后的对象
})
.collect(Collectors.toList()); // 最后需要收集成List
ExcelUtil<MaterialStorageDto> util = new ExcelUtil<>(MaterialStorageDto.class);
util.exportExcel(response, resultList, "综合查询--在库机具设备详情");
}
/**
* 查询在用设备详情
* @param bean
@ -403,4 +427,55 @@ public class MaterialMachineController extends BaseController {
List<MaterialRetainedEquipmentInfo> list = materialMachineService.getBranchList(bean);
return AjaxResult.success(list);
}
/**
* 材料站设备保有量查询
* @param bean
* @return
*/
@ApiOperation(value = "综合查询--材料站设备保有量查询")
@GetMapping("/getStoreNumAndUseList")
public AjaxResult getStoreNumAndUseList(MaterialRetainedEquipmentInfo bean) {
bean.setIsExport(1);
if (bean.getIsApp() != null && bean.getIsApp() == 0) {
return AjaxResult.success(materialMachineService.getStoreNumAndUseList(bean));
}
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
List<MaterialStorageAndUseNumInfo> list = materialMachineService.getStoreNumAndUseList(bean);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 保有设备总量查询不带分页
* @param bean
* @return
*/
@ApiOperation(value = "综合查询--保有设备总量查询不带分页")
@GetMapping("/getRetainedEquipmentListNoPage")
public AjaxResult getRetainedEquipmentListNoPage(MaterialRetainedEquipmentInfo bean) {
bean.setIsExport(0);
List<MaterialStorageAndUseNumInfo> list = materialMachineService.getStoreNumAndUseList(bean);
MaterialStorageAndUseNumInfo dto = new MaterialStorageAndUseNumInfo();
if (CollectionUtils.isNotEmpty(list)) {
MaterialStorageAndUseNumInfo retainedEquipmentInfo = list.get(0);
dto.setStoreNum(retainedEquipmentInfo.getStoreNum());
dto.setUsNum(retainedEquipmentInfo.getUsNum());
}
return AjaxResult.success(dto);
}
/**
* 导出材料站设备保有量查询
* @param response
* @param bean
*/
@ApiOperation(value = "综合查询--材料站设备保有量查询")
@PostMapping("/exportStoreNumAndUseList")
public void exportStoreNumAndUseList(HttpServletResponse response, MaterialRetainedEquipmentInfo bean) {
bean.setIsExport(0);
List<MaterialStorageAndUseNumInfo> list = materialMachineService.getStoreNumAndUseList(bean);
ExcelUtil<MaterialStorageAndUseNumInfo> util = new ExcelUtil<>(MaterialStorageAndUseNumInfo.class);
util.exportExcel(response, list, "综合查询--材料站设备保有量查询");
}
}

View File

@ -216,4 +216,7 @@ public class MaterialBackApplyInfo implements Serializable {
*/
private List<String> agreementIds;
@ApiModelProperty(value = "是否电子签名 0 是1 否")
private Integer isElectronicSign;
}

View File

@ -0,0 +1,81 @@
package com.bonus.material.clz.domain.machine;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 机具入库查询详情
* @Author ma_sh
* @create 2024/12/19 9:50
*/
@Data
public class MaterialStorageDto {
@ApiModelProperty(value = "主键id")
private Integer id;
@ApiModelProperty(value = "机具名称")
@Excel(name = "机具名称")
private String typeName;
@ApiModelProperty(value = "规格ID")
private Integer typeId;
@ApiModelProperty(value = "规格型号")
@Excel(name = "规格型号")
private String typeModelName;
@ApiModelProperty(value = "入库数量")
private BigDecimal storeNum;
@ApiModelProperty(value = "购置单价")
@Excel(name = "租赁价(元)")
private BigDecimal buyPrice;
@ApiModelProperty(value = "设备编码")
@Excel(name = "设备编码")
private String maCode;
@ApiModelProperty(value = "库管员")
private String maKeeper;
@ApiModelProperty(value = "操作人")
@Excel(name = "操作人")
private String inputUser;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date inputTime;
@ApiModelProperty(value = "入库方式")
private String inputType;
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "班组id")
private String teamId;
@ApiModelProperty(value = "班组名称")
private String teamName;
@ApiModelProperty(value = "领料id")
private String leaseId;
@ApiModelProperty(value = "领料编码")
private String code;
@ApiModelProperty(value = "工程id")
private String proId;
@ApiModelProperty(value = "编码ID")
private String maId;
}

View File

@ -65,8 +65,11 @@ public class MaterialUseStorageInfo {
@Excel(name = "班组")
private String teamName;
@ApiModelProperty(value = "分包单位")
private String subUnitName;
@ApiModelProperty(value="工程名称")
@Excel(name = "工程名称")
@Excel(name = "工程名称", width = 40)
private String proName;
@ApiModelProperty(value = "关键字")

View File

@ -0,0 +1,227 @@
package com.bonus.material.clz.domain.vo;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @description 综合查询--保有设备总量查询
* @author ma_sh
* @date 2024/2/26 14:51
*/
@ApiModel(description = "保有设备总量查询")
@Data
public class MaterialStorageAndUseNumInfo {
private static final long serialVersionUID = 2227217051604273598L;
@ApiModelProperty(value = "是否app 0 是1 否")
private Integer isApp;
@ApiModelProperty(value = "是否导出 0 是1 否")
private Integer isExport;
@ApiModelProperty(value = "主键id")
private Integer id;
@ApiModelProperty(value = "工程id")
private String proId;
@ApiModelProperty(value = "分公司")
private String impUnitName;
@ApiModelProperty(value = "项目部")
private String departName;
@ApiModelProperty(value = "工程名称")
@Excel(name = "工程名称", width = 50)
private String proName;
@ApiModelProperty(value = "施工类型")
@Excel(name = "施工类型")
private String constructionType;
@ApiModelProperty(value = "物资类型")
@Excel(name = "物资类型")
private String materialType;
@ApiModelProperty(value = "物资名称")
@Excel(name = "物资名称")
private String typeName;
@ApiModelProperty(value = "规格ID")
private Integer typeId;
@ApiModelProperty(value = "规格型号")
@Excel(name = "规格型号")
private String typeModelName;
@ApiModelProperty(value = "机具类型")
private String jiJuType;
@ApiModelProperty(value = "计量单位")
@Excel(name = "计量单位")
private String unit;
@ApiModelProperty(value = "在库数量")
@Excel(name = "在库数量",align = HorizontalAlignment.RIGHT)
private BigDecimal storeNum;
@ApiModelProperty(value = "在用数量")
@Excel(name = "在用数量",align = HorizontalAlignment.RIGHT)
private BigDecimal usNum;
@ApiModelProperty(value = "数量")
private BigDecimal allNum;
@ApiModelProperty(value = "购置单价")
private BigDecimal buyPrice;
@ApiModelProperty(value = "管理模式")
private String manageType;
@ApiModelProperty(value = "创建者")
private String createBy;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "更新者")
private String updateBy;
@ApiModelProperty(value = "更新时间 ")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
/** 1.机具仓储 2.调试仓储 */
private String maType;
private String maTypeName;
@ApiModelProperty(value = "一级类型id")
private Integer firstTypeId;
@ApiModelProperty(value = "二级类型id")
private Integer secondTypeId;
@ApiModelProperty(value = "三级类型id")
private Integer thirdTypeId;
private List<MaterialStorageAndUseNumInfo> modelList;
/**
* 是否伸展APP
*/
private boolean expanded = false;
/**
* 检验状态
*/
private String checkStatus;
private String maCode;
/** 本次检验日期 */
@ApiModelProperty(value = "本次检验日期")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date thisCheckTime;
/** 下次检验日期 */
@ApiModelProperty(value = "下次检验日期")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date nextCheckTime;
/**
* 状态(0 =正常1= 3个月检测到期2= 1个月检测到期3= 已过期)
*/
private String status;
/** 正常设备数量 */
private long normalNum;
/** 3个月检测到期设备数量 */
private long threeMonthNum;
/** 1个月检测到期设备数量 */
private long oneMonthNum;
/** 已过期设备数量 */
private long expiredNum;
@ApiModelProperty(value = "班组id")
private String teamId;
/**
* 班组长账号
*/
private String teamLeaderIdCard;
@ApiModelProperty(value = "i8工程id")
private String externalId;
@ApiModelProperty(value = "身份证号码")
private String idCard;
@ApiModelProperty(value = "实施单位id")
private String impUnit;
/**
* i8工程id集合
*/
private List<String> projectIdList;
@ApiModelProperty(value = "协议id集合")
private List<Integer> agreementIdList;
private Long maId;
@ApiModelProperty(value = "领料人")
private String code;
@ApiModelProperty(value = "领料人")
private String leasePerson;
@ApiModelProperty(value = "协议id")
private Long agreementId;
private Long deptId;
@ApiModelProperty(value = "项目部名称")
private String proCenter;
@ApiModelProperty(value = "物资类型")
private String materialName;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
private String unitValue;
@ApiModelProperty(value = "报告编码")
private String reportCode;
@ApiModelProperty(value = "报告路径")
private String reportUrl;
}

View File

@ -3,13 +3,10 @@ package com.bonus.material.clz.mapper;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.material.clz.domain.TeamVo;
import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo;
import com.bonus.material.clz.domain.vo.MaterialRetainedTeamTotalVo;
import com.bonus.material.clz.domain.vo.MaterialRetainedTeamVo;
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
import com.bonus.material.clz.domain.vo.*;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.clz.domain.BmTeam;
import com.bonus.material.clz.domain.machine.MaterialStorageInfo;
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
import java.util.List;
@ -256,4 +253,11 @@ public interface MaterialMachineMapper {
* @return
*/
List<MaterialRetainedEquipmentInfo> getSubUnitList(MaterialRetainedEquipmentInfo bean);
/**
* 获取库存量
* @param bean
* @return
*/
List<MaterialStorageAndUseNumInfo> getStoreNumAndUseList(MaterialRetainedEquipmentInfo bean);
}

View File

@ -3,12 +3,9 @@ package com.bonus.material.clz.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.clz.domain.TeamVo;
import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo;
import com.bonus.material.clz.domain.vo.MaterialRetainedTeamTotalVo;
import com.bonus.material.clz.domain.vo.MaterialRetainedTeamVo;
import com.bonus.material.clz.domain.vo.MaterialTotalMentInfo;
import com.bonus.material.clz.domain.vo.*;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.clz.domain.machine.MaterialStorageInfo;
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
import java.util.List;
@ -178,4 +175,11 @@ public interface MaterialMachineService {
* @return
*/
List<MaterialRetainedEquipmentInfo> getBranchList(MaterialRetainedEquipmentInfo bean);
/**
* 保有设备总量查询
* @param bean
* @return
*/
List<MaterialStorageAndUseNumInfo> getStoreNumAndUseList(MaterialRetainedEquipmentInfo bean);
}

View File

@ -6,6 +6,7 @@ import com.alibaba.nacos.common.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.basic.domain.RetainedEquipmentInfo;
import com.bonus.material.clz.domain.TeamVo;
import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo;
import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo;
@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -1121,6 +1123,60 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
return impUnitNameList;
}
/**
* 获取库存和在用量
* @param bean
* @return
*/
@Override
public List<MaterialStorageAndUseNumInfo> getStoreNumAndUseList(MaterialRetainedEquipmentInfo bean) {
BigDecimal totalStoreNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
String username = SecurityUtils.getLoginUser().getUsername();
// 根据用户名判断用户是否为班组长
BmTeam teamData = materialMachineMapper.getTeamData(username);
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
if (teamData == null) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
if (CollectionUtils.isNotEmpty(departId)) {
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
}
}
}
// 部门查询赋值
extractedDept(bean);
}
//查询目前还有库存的设备
List<MaterialStorageAndUseNumInfo> recordList = materialMachineMapper.getStoreNumAndUseList(bean);
if (!CollectionUtils.isEmpty(recordList)){
if (teamData != null){
// 将sortedList中班组身份证号与username相同的元素过滤处理
recordList = recordList.stream()
.filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard()))
.collect(Collectors.toList());
}
for (MaterialStorageAndUseNumInfo record : recordList) {
totalStoreNum = totalStoreNum.add(record.getStoreNum());
totalUsNum = totalUsNum.add(record.getUsNum());
}
}
if (bean.getIsExport() == 0) {
MaterialStorageAndUseNumInfo info = new MaterialStorageAndUseNumInfo();
info.setStoreNum(totalStoreNum);
info.setUsNum(totalUsNum);
info.setUnit("合计");
recordList.add(0, info);
}
return recordList;
}
/**
* 设置分公司名称如果有
* @param impUnit

View File

@ -227,7 +227,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(IFNULL(bad.pre_num, 0)) AS backNum,
bp.external_id AS externalId,
bp.imp_unit AS impUnit,
bt.bzz_idcard AS idCard
bt.bzz_idcard AS idCard,
CASE WHEN bai.back_sign_url IS NOT NULL
THEN 0
ELSE 1
END as isElectronicSign
FROM
clz_back_apply_info bai
LEFT JOIN clz_back_apply_details bad on bad.parent_id = bai.id

View File

@ -1755,4 +1755,182 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bz.ssfbdw
</select>
<select id="getStoreNumAndUseList" resultType="com.bonus.material.clz.domain.vo.MaterialStorageAndUseNumInfo">
SELECT
mt.type_id AS typeId,
mt4.type_name AS constructionType,
mt3.type_name AS materialType,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
mt.unit_name AS unit,
subquery1.proId AS proId,
subquery1.proName AS proName,
subquery1.externalId AS externalId,
subquery1.impUnit AS impUnit,
subquery1.idCard AS idCard,
CASE
WHEN IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) &lt; 0
THEN 0
ELSE IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0)
END
AS storeNum,
IFNULL(subquery3.usNum, 0) AS usNum,
subquery1.proCenter AS departName,
subquery1.departName AS impUnitName,
CASE mt.manage_type
WHEN 0 THEN
'编码'
ELSE
'数量'
END manageType,
mt.unit_value AS unitValue,
CASE mt.jiju_type
WHEN 2 THEN
'安全工器具'
ELSE
'施工机具'
END jiJuType
FROM ma_type mt
LEFT JOIN (
SELECT
mt.type_id,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS usNum,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
df.project_dept AS proCenter,
sd.dept_name AS departName
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.is_slt = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
AND bp.external_id IS NOT NULL
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name like concat('%',#{impUnitName},'%')
</if>
<if test="proName != null and proName != ''">
AND bp.pro_name like concat('%',#{proName},'%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center like concat('%',#{departName},'%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
and bp.imp_unit = #{impUnit}
</if>
<if test="jiJuType != null and jiJuType != ''">
AND mt.jiju_type = #{jiJuType}
</if>
GROUP BY mt.type_id,
bp.pro_id
) AS subquery1 ON mt.type_id = subquery1.type_id
LEFT JOIN (
SELECT
mt.type_id,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS usNum,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
df.project_dept AS proCenter,
sd.dept_name AS departName
FROM
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name like concat('%',#{impUnitName},'%')
</if>
<if test="proName != null and proName != ''">
AND bp.pro_name like concat('%',#{proName},'%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center like concat('%',#{departName},'%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
and bp.imp_unit = #{impUnit}
</if>
<if test="jiJuType != null and jiJuType != ''">
AND mt.jiju_type = #{jiJuType}
</if>
GROUP BY mt.type_id,
bp.pro_id
) AS subquery3
ON mt.type_id = subquery3.type_id
AND subquery1.proId = subquery3.proId
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE mt.`level` = 4 and mt.del_flag = '0'
and subquery1.proName is not null
GROUP BY mt.type_id,
subquery1.proId
</select>
</mapper>