材料站点导出及查询优化

This commit is contained in:
liux 2025-10-10 20:56:27 +08:00
parent b252062602
commit b75ab65778
7 changed files with 311 additions and 166 deletions

View File

@ -0,0 +1,83 @@
package com.bonus.material.clz.domain.back;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author xliu
* @date 2025/10/10 15:41
*/
@Data
public class MaterialBackExportVO {
@ApiModelProperty(value = "序号")
@Excel(name = "序号", isSequence = true, sort = 0)
private String serialNumber;
@Excel(name = "分公司")
@ApiModelProperty(value = "分公司")
private String impUnitName;
@Excel(name = "退料工程")
@ApiModelProperty(value = "退料工程")
private String proName;
@Excel(name = "单位名称")
@ApiModelProperty(value = "单位名称")
private String unitName;
@Excel(name = "退料人")
@ApiModelProperty(value = "退料人")
private String backPerson;
@ApiModelProperty(value = "物资类型")
private String materialType;
@Excel(name = "退料单号")
@ApiModelProperty(value = "退料单号")
private String code;
@ApiModelProperty(value = "工器具名称")
@Excel(name = "工器具名称")
private String materialName;
@Excel(name = "规格型号")
@ApiModelProperty(value = "规格型号")
private String typeModelName;
@ApiModelProperty(value = "类型名称")
@Excel(name = "类型名称")
private String typeCode;
/** 退料数量 */
@ApiModelProperty(value = "预退数量")
@Excel(name = "预退数量", cellType = Excel.ColumnType.NUMERIC)
private BigDecimal backNum;
@Excel(name = "退料数量",cellType = Excel.ColumnType.NUMERIC)
@ApiModelProperty(value = "退料数量")
private BigDecimal outNum;
@ApiModelProperty(value = "计量单位")
@Excel(name = "计量单位")
private String unit;
@Excel(name = "退料时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "退料时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date backTime;
}

View File

@ -4,6 +4,7 @@ import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.clz.domain.back.MaterialBackApplyDetails;
import com.bonus.material.clz.domain.back.MaterialBackApplyInfo;
import com.bonus.material.clz.domain.back.MaterialBackApplyTotalInfo;
import com.bonus.material.clz.domain.back.MaterialBackExportVO;
import com.bonus.material.clz.domain.vo.back.MaterialBackApplyRequestVo;
import com.bonus.material.clz.domain.vo.back.MaterialBackMaCodeVo;
@ -120,4 +121,6 @@ public interface MaterialBackApplyInfoService {
* @return
*/
AjaxResult getMachine(MaterialBackApplyInfo dto);
List<MaterialBackExportVO> exportBackInfoExcl(MaterialBackApplyInfo bean);
}

View File

@ -50,7 +50,6 @@ import com.bonus.material.work.domain.SysWorkflowRecordHistory;
import com.bonus.material.work.domain.SysWorkflowType;
import com.bonus.material.work.mapper.*;
import com.bonus.system.api.domain.SysUser;
import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;

View File

@ -13,6 +13,7 @@ import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.bean.BeanUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.back.domain.BackApplyInfo;
@ -20,6 +21,7 @@ import com.bonus.material.back.domain.MaCodeDto;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.clz.domain.BmTeam;
import com.bonus.material.clz.domain.back.MaterialBackExportVO;
import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo;
import com.bonus.material.clz.mapper.IwsTeamUserMapper;
import com.bonus.material.clz.mapper.MaterialMachineMapper;
@ -92,7 +94,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名判断用户是否为班组长
teamData = materialMachineMapper.getTeamData(username);
teamData = materialMachineMapper.getTeamData(username);
if (teamData == null) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
@ -226,6 +228,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
*/
@Override
public List<MaterialBackApplyInfo> getTotalList(MaterialBackApplyInfo backApplyInfo) {
long time1 = System.currentTimeMillis();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
String username = SecurityUtils.getLoginUser().getUsername();
// 检查用户是否具有特殊角色
@ -234,16 +237,23 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
if (!hasSpecialRole) {
// 根据用户名判断用户是否为班组长
teamData = materialMachineMapper.getTeamData(username);
long time2 = System.currentTimeMillis();
System.err.println("查询用户信息耗时time2 - time1" + (time2 - time1));
if (teamData == null) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
long time3 = System.currentTimeMillis();
System.err.println("查询用户所属项目部信息耗时time3 - time2" + (time3 - time2));
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
backApplyInfo.setProjectIdList(projectIdList);
}
long time4 = System.currentTimeMillis();
System.err.println("查询用户所属项目部工程信息耗时time4 - time3" + (time4 - time3));
}
}
long time5 = System.currentTimeMillis();
List<MaterialBackApplyInfo> list = materialBackInfoMapper.getTotalList(backApplyInfo);
if (!hasSpecialRole) {
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
@ -252,6 +262,8 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
list.removeIf(info -> !deptId.toString().equals(info.getImpUnit()));
}
}
long time6 = System.currentTimeMillis();
System.err.println("查询总站点退料记录数据耗时time6 - time5" + (time6 - time5));
if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
// 班组长权限
if (teamData != null) {
@ -264,6 +276,8 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
list = filterList(list, username);
}*/
}
long time7 = System.currentTimeMillis();
System.err.println("过滤数据耗时time7 - time6" + (time7 - time6));
// 新增typeName过滤条件
if (!org.springframework.util.CollectionUtils.isEmpty(list) && !StringUtils.isBlank(backApplyInfo.getTypeName())) {
list = list.stream()
@ -281,6 +295,8 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
// 查询所有未结算的工程
List<String> projectIdList = mapper.getUnsettledProId();
long time8 = System.currentTimeMillis();
System.err.println("查询所有未结算的工程耗时time8 - time7" + (time8 - time7));
// 使用 HashSet 来加速查找过程
Set<String> unsettledProjectIds = new HashSet<>(projectIdList);
// 过滤掉不在未结算工程集合内的设备
@ -294,6 +310,8 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
iterator.remove();
}
}
long time9 = System.currentTimeMillis();
System.err.println("过滤未结算工程耗时time9 - time8" + (time9 - time8));
}
return list;
}
@ -640,7 +658,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名判断用户是否为班组长
teamData = materialMachineMapper.getTeamData(username);
teamData = materialMachineMapper.getTeamData(username);
if (teamData == null) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
@ -1303,4 +1321,26 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
(item.getBackPerson() != null && item.getBackPerson().contains(keyWord)) ||
(item.getCode() != null && item.getCode().contains(keyWord));
}
@Override
public List<MaterialBackExportVO> exportBackInfoExcl(MaterialBackApplyInfo backApplyInfo) {
List<MaterialBackApplyInfo> list = this.getTotalList(backApplyInfo);
List<MaterialBackExportVO> result = new ArrayList<>();
for (MaterialBackApplyInfo bean: list) {
bean.setParentId(bean.getId());
List<MaterialBackApplyInfo> details = this.getDetailsList(bean);
for (MaterialBackApplyInfo detail: details){
MaterialBackExportVO vo = new MaterialBackExportVO();
BeanUtils.copyProperties(bean, vo);
vo.setUnit(detail.getUnitNames());
vo.setOutNum(detail.getBackNum());
vo.setBackNum(detail.getBackNum());
vo.setTypeModelName(detail.getModelCode());
vo.setMaterialName(detail.getTypeName());
vo.setTypeCode(detail.getTypeCode());
result.add( vo);
}
}
return result;
}
}

View File

@ -10,10 +10,14 @@ spring:
# 服务注册地址
server-addr: 127.0.0.1:8848
namespace: sgzb_bns
username: nacos
password: nacos
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
namespace: sgzb_bns
username: nacos
password: nacos
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.clz.mapper.MaterialBackInfoMapper">
<insert id="insertBackApplyInfo" useGeneratedKeys="true" keyProperty="id">
insert into clz_back_apply_info
@ -128,19 +128,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateStlInfo">
update clz_slt_agreement_info
set end_time = now(),
update_time = now(),
back_id = #{record.id},
status = '1'
update_time = now(),
back_id = #{record.id},
status = '1'
where id = #{info.id}
</update>
<update id="updateStlInfoTwo">
update clz_slt_agreement_info
set num = #{backNum},
end_time = now(),
update_time = now(),
back_id = #{record.id},
status = '1'
end_time = now(),
update_time = now(),
back_id = #{record.id},
status = '1'
where id = #{info.id}
</update>
@ -343,7 +343,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
END isZz,
bu.bzz_idcard AS idCard
FROM
back_apply_info bai
(select * from back_apply_info
<where>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and create_time between concat(#{startTime},' 00:00:00') and concat(#{endTime},' 23:59:59')
</if>
</where>
) bai
LEFT JOIN back_check_details bad on bad.parent_id = bai.id
LEFT JOIN tm_task tt on tt.task_id = bai.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
@ -379,9 +385,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="proId != null">
and bp.pro_id = #{proId}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and DATE_FORMAT( bai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<!-- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">-->
<!-- <![CDATA[and DATE_FORMAT( bai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>-->
<!-- </if>-->
<if test="appTaskStatus != null and appTaskStatus == 0">
and tt.task_status = #{appTaskStatus}
</if>
@ -403,59 +409,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getDetailsList" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
SELECT
mt.type_name AS modelCode,
mt1.type_name AS typeName,
mt2.type_name AS typeCode,
mt.manage_type AS manageType,
sum(bcd.back_num) AS backNum,
mt.unit_name AS unitNames,
bcd.remark AS remark
mt.type_name AS modelCode,
mt1.type_name AS typeName,
mt2.type_name AS typeCode,
mt.manage_type AS manageType,
sum(bcd.back_num) AS backNum,
mt.unit_name AS unitNames,
bcd.remark AS remark
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai ON bcd.parent_id = bai.id
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id and mt.del_flag = 0
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = 0
back_check_details bcd
LEFT JOIN back_apply_info bai ON bcd.parent_id = bai.id
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id and mt.del_flag = 0
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = 0
WHERE
bcd.parent_id = #{parentId}
bcd.parent_id = #{parentId}
group by bcd.type_id
</select>
<select id="selectBackApplyInfoById" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
SELECT
bai.id AS id,
bai.CODE AS CODE,
bai.task_id AS taskId,
bai.back_person AS backPerson,
bai.phone AS phone,
bai.create_by AS createBy,
bai.create_time AS createTime,
bai.update_by AS updateBy,
bai.update_time AS updateTime,
bai.remark AS remark,
bai.STATUS AS STATUS,
bai.print_status AS printStatus,
ba.agreement_id AS agreementId,
bt.unit_id AS teamId,
bt.unit_name AS teamName,
bp.pro_id AS proId,
bp.pro_name AS proName,
bai.direct_audit_by AS directAuditBy,
bai.back_sign_url AS backSignUrl,
bai.back_sign_type AS backSignType,
bp.external_id AS externalId
bai.id AS id,
bai.CODE AS CODE,
bai.task_id AS taskId,
bai.back_person AS backPerson,
bai.phone AS phone,
bai.create_by AS createBy,
bai.create_time AS createTime,
bai.update_by AS updateBy,
bai.update_time AS updateTime,
bai.remark AS remark,
bai.STATUS AS STATUS,
bai.print_status AS printStatus,
ba.agreement_id AS agreementId,
bt.unit_id AS teamId,
bt.unit_name AS teamName,
bp.pro_id AS proId,
bp.pro_name AS proName,
bai.direct_audit_by AS directAuditBy,
bai.back_sign_url AS backSignUrl,
bai.back_sign_type AS backSignType
bp.external_id AS externalId
FROM
clz_back_apply_info bai
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN clz_bm_agreement_info ba ON ba.agreement_id = tta.agreement_id
AND ba.`status` = 1
LEFT JOIN bm_unit bt ON bt.unit_id = ba.unit_id
AND bt.del_flag = '0'
LEFT JOIN bm_project bp ON ba.project_id = bp.pro_id
AND bp.del_flag = '0'
clz_back_apply_info bai
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN clz_bm_agreement_info ba ON ba.agreement_id = tta.agreement_id
AND ba.`status` = 1
LEFT JOIN bm_unit bt ON bt.unit_id = ba.unit_id
AND bt.del_flag = '0'
LEFT JOIN bm_project bp ON ba.project_id = bp.pro_id
AND bp.del_flag = '0'
WHERE
bai.id = #{id}
bai.id = #{id}
</select>
<select id="selectBackApplyDetailsListByTaskId" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyDetails">
@ -499,25 +505,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByCode" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
SELECT
bcd.ma_id AS maId,
mm.ma_code as maCode,
bcd.type_id AS typeId,
mt2.type_name AS materialType,
mt.type_name AS typeName,
mt1.type_name AS materialName,
bcd.ap_detection AS apDetection,
sd.dict_label AS maStatusName,
bcd.bad_num AS badNum,
bcd.good_num AS goodNum,
mm.ma_status AS maStatus
bcd.ma_id AS maId,
mm.ma_code as maCode,
bcd.type_id AS typeId,
mt2.type_name AS materialType,
mt.type_name AS typeName,
mt1.type_name AS materialName,
bcd.ap_detection AS apDetection,
sd.dict_label AS maStatusName,
bcd.bad_num AS badNum,
bcd.good_num AS goodNum,
mm.ma_status AS maStatus
FROM
clz_back_check_details bcd
left join ma_machine mm on bcd.ma_id = mm.ma_id
left join ma_type mt ON mt.type_id = mm.type_id and mt.del_flag = 0
left join ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
LEFT JOIN sys_dict_data sd ON mm.ma_status = sd.dict_value
and sd.dict_type = 'ma_machine_status'
clz_back_check_details bcd
left join ma_machine mm on bcd.ma_id = mm.ma_id
left join ma_type mt ON mt.type_id = mm.type_id and mt.del_flag = 0
left join ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
LEFT JOIN sys_dict_data sd ON mm.ma_status = sd.dict_value
and sd.dict_type = 'ma_machine_status'
where bcd.parent_id = #{id}
</select>
@ -547,27 +553,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getDetailsById" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyDetails">
SELECT
mt1.type_name as typeName,
mt.type_name as typeModel,
bcd.type_id as typeId,
bcd.back_num as preNum,
bcd.ma_id as maId,
mm.ma_code as maCode,
bcd.parent_id as parentId,
bcd.create_by as createBy,
bcd.create_time as createTime,
bai.task_id as taskId,
bcd.ap_detection as apDetection
mt1.type_name as typeName,
mt.type_name as typeModel,
bcd.type_id as typeId,
bcd.back_num as preNum,
bcd.ma_id as maId,
mm.ma_code as maCode,
bcd.parent_id as parentId,
bcd.create_by as createBy,
bcd.create_time as createTime,
bai.task_id as taskId,
bcd.ap_detection as apDetection
FROM
clz_back_check_details bcd
LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
LEFT JOIN clz_back_apply_info bai ON bcd.parent_id = bai.id
clz_back_check_details bcd
LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
LEFT JOIN clz_back_apply_info bai ON bcd.parent_id = bai.id
WHERE
bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
</select>
<select id="selectBackDetails" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
@ -629,7 +635,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getBackInfoDetails" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyTotalInfo">
select
select
sd.dept_name AS impUnitName,
bp.pro_center AS departName,
bcd.id AS id,
@ -741,23 +747,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
SELECT
mt.type_id as typeId,
mt1.type_name as materialName,
mt.type_name as typeName,
mt.parent_id as parentId,
mt.unit_name as unitName,
mt.unit_value as unitValue,
mt.manage_type as manageType,
SUM(sai.num) AS num,
mt.LEVEL as level,
clai.lease_style as leaseStyle
mt.type_id as typeId,
mt1.type_name as materialName,
mt.type_name as typeName,
mt.parent_id as parentId,
mt.unit_name as unitName,
mt.unit_value as unitValue,
mt.manage_type as manageType,
SUM(sai.num) AS num,
mt.LEVEL as level,
clai.lease_style as leaseStyle
FROM
ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
WHERE
sai.STATUS = '0'
sai.STATUS = '0'
<if test="agreementIds != null ">
and sai.agreement_id in
@ -767,35 +773,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
GROUP BY
mt.type_id
mt.type_id
</select>
<select id="getMachineById" resultType="com.bonus.material.clz.domain.vo.MaterialMaCodeVo">
SELECT
mm.ma_id AS maId,
mm.ma_code AS maCode,
'在用' AS maStatusName,
mt1.type_name AS materialName,
mt.type_id AS typeId,
mt.type_name AS typeName,
mt2.type_name AS materialType
mm.ma_id AS maId,
mm.ma_code AS maCode,
'在用' AS maStatusName,
mt1.type_name AS materialName,
mt.type_id AS typeId,
mt.type_name AS typeName,
mt2.type_name AS materialType
FROM
clz_lease_out_details lod
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
AND mt2.del_flag = '0'
LEFT JOIN clz_slt_agreement_info sai on lod.type_id = sai.type_id
and sai.ma_id = lod.ma_id
LEFT JOIN clz_bm_agreement_info ba ON sai.agreement_id = ba.agreement_id
clz_lease_out_details lod
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
AND mt2.del_flag = '0'
LEFT JOIN clz_slt_agreement_info sai on lod.type_id = sai.type_id
and sai.ma_id = lod.ma_id
LEFT JOIN clz_bm_agreement_info ba ON sai.agreement_id = ba.agreement_id
WHERE
sai.status = '0'
AND mt.type_id = #{typeId}
AND ba.unit_id = #{teamId}
AND ba.project_id = #{proId}
sai.status = '0'
AND mt.type_id = #{typeId}
AND ba.unit_id = #{teamId}
AND ba.project_id = #{proId}
<if test="maCode != null and maCode != ''">
AND mm.ma_code LIKE CONCAT(CONCAT('%', #{maCode}), '%')
</if>
@ -804,28 +810,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAgreementId" resultType="java.lang.Long">
SELECT
tt.agreement_id AS agreementId
tt.agreement_id AS agreementId
FROM
clz_back_apply_info ba
LEFT JOIN tm_task_agreement tt ON ba.task_id = tt.task_id
clz_back_apply_info ba
LEFT JOIN tm_task_agreement tt ON ba.task_id = tt.task_id
WHERE
ba.id = #{id}
ba.id = #{id}
</select>
<select id="selectByAgreementIdAndTypeIdAndMaId" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
SELECT
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId
FROM
clz_slt_agreement_info
clz_slt_agreement_info
WHERE
status = '0'
AND agreement_id = #{agreementId}
AND type_id = #{typeId}
<if test="maId != null">
status = '0'
AND agreement_id = #{agreementId}
AND type_id = #{typeId}
<if test="maId != null">
AND ma_id = #{maId}
</if>
</if>
</select>
<select id="selectByAgreementIdAndTypeId" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
@ -892,26 +898,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getAgreementInfo" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyInfo">
select
csa.unit_id AS teamId,
csa.project_id AS proId
from
tm_task_agreement tta
LEFT JOIN clz_bm_agreement_info csa ON tta.agreement_id = csa.agreement_id
csa.unit_id AS teamId,
csa.project_id AS proId
from
tm_task_agreement tta
LEFT JOIN clz_bm_agreement_info csa ON tta.agreement_id = csa.agreement_id
WHERE tta.task_id = #{taskId}
</select>
<select id="getAgreementList" resultType="java.lang.String">
select csa.agreement_id AS agreementId
from clz_bm_agreement_info csa
where csa.unit_id = #{teamId}
and csa.project_id = #{proId}
and csa.project_id = #{proId}
</select>
<select id="getLeaseAgreement" resultType="java.lang.String">
select csa.agreement_id AS agreementId
from clz_bm_agreement_info csa
where csa.unit_id = #{teamId}
and csa.project_id = #{proId}
Limit 1
and csa.project_id = #{proId}
Limit 1
</select>
<select id="getLeaseOutSignList" resultType="com.bonus.common.biz.domain.lease.LeaseOutSign">

View File

@ -1173,15 +1173,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY bzgl_bz.bzmc
</select>
<select id="getUnsettledProId" resultType="java.lang.String">
SELECT DISTINCT bp.pro_id as proId
<!-- 数据量小的时候用上面的SQL数据量大的时候用下面的sql -->
SELECT bp.pro_id as proId
FROM bm_project bp
WHERE EXISTS(
SELECT 1
FROM bm_agreement_info bai
INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id
WHERE bai.project_id = bp.pro_id
AND sai.is_slt = 0
)
AND bp.pro_id IS NOT NULL
WHERE bp.pro_id IS NOT NULL
AND bp.pro_id IN (
SELECT bai.project_id
FROM bm_agreement_info bai
INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id
WHERE sai.is_slt = 0
)
<!-- SELECT DISTINCT bp.pro_id as proId-->
<!-- FROM bm_project bp-->
<!-- WHERE EXISTS(-->
<!-- SELECT 1-->
<!-- FROM bm_agreement_info bai-->
<!-- INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id-->
<!-- WHERE bai.project_id = bp.pro_id-->
<!-- AND sai.is_slt = 0-->
<!-- )-->
<!-- AND bp.pro_id IS NOT NULL-->
</select>
</mapper>