材料站优化
This commit is contained in:
		
							parent
							
								
									73f3c4bcbf
								
							
						
					
					
						commit
						e844e4a0a3
					
				| 
						 | 
				
			
			@ -88,7 +88,7 @@ public class BmQrcodeInfoController extends BaseController
 | 
			
		|||
     */
 | 
			
		||||
    @ApiOperation(value = "新增二维码管理")
 | 
			
		||||
    @PreventRepeatSubmit
 | 
			
		||||
    @RequiresPermissions("basic:info:add")
 | 
			
		||||
    //@RequiresPermissions("basic:info:add")
 | 
			
		||||
    @SysLog(title = "二维码管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增二维码管理")
 | 
			
		||||
    @PostMapping("/add")
 | 
			
		||||
    public AjaxResult add(@RequestBody BmQrcodeInfo bmQrcodeInfo)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import com.bonus.common.core.annotation.Excel;
 | 
			
		|||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,7 @@ public class MaterialRetainedTeamTotalVo {
 | 
			
		|||
    private String teamLeaderIdCard;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "在用数量")
 | 
			
		||||
    @Excel(name = "库存")
 | 
			
		||||
    @Excel(name = "库存", cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
 | 
			
		||||
    private BigDecimal usNum;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "关键字")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -306,4 +306,11 @@ public interface MaterialMachineMapper {
 | 
			
		|||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    List<MaterialProvideNumInfo> batchQueryUseDemand(@Param("list") List<Map<String, Object>> queryParams);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询分包商领用数据
 | 
			
		||||
     * @param bean
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    List<MaterialRetainedEquipmentInfo> getSubInfoList(MaterialRetainedEquipmentInfo bean);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,13 +168,18 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
 | 
			
		||||
        // 查询目前在用的设备信息
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> usList = materialMachineMapper.getUsInfoList(bean);
 | 
			
		||||
        // 查询目前还有库存的设备
 | 
			
		||||
        // 查询目前还有库存的设备,仅查单位类型为项目部的
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> recordList = materialMachineMapper.getRetainInfoList(bean);
 | 
			
		||||
        // 查询分包商领用数据,不作为库存,作为再用数据
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> subList = materialMachineMapper.getSubInfoList(bean);
 | 
			
		||||
 | 
			
		||||
        // 数据合并
 | 
			
		||||
        if (!CollectionUtils.isEmpty(recordList)) {
 | 
			
		||||
            usList.addAll(recordList);
 | 
			
		||||
        }
 | 
			
		||||
        if (!CollectionUtils.isEmpty(subList)) {
 | 
			
		||||
            usList.addAll(subList);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!CollectionUtils.isEmpty(usList)) {
 | 
			
		||||
            if (teamData != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -305,9 +310,11 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
        }
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> list = materialMachineMapper.getTeamUseNumList(bean);
 | 
			
		||||
        Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
 | 
			
		||||
        if (!CollectionUtils.isEmpty(list) && deptId != null) {
 | 
			
		||||
            // 删除元素
 | 
			
		||||
            list.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
 | 
			
		||||
        if (teamData == null) {
 | 
			
		||||
            if (!CollectionUtils.isEmpty(list) && deptId != null) {
 | 
			
		||||
                // 删除元素
 | 
			
		||||
                list.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
 | 
			
		||||
            if (teamData != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -315,9 +322,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
                list = list.stream()
 | 
			
		||||
                        .filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard()))
 | 
			
		||||
                        .collect(Collectors.toList());
 | 
			
		||||
            } /*else {
 | 
			
		||||
                list = filterInfo(list, username);
 | 
			
		||||
            }*/
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (CollectionUtils.isNotEmpty(list)) {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -415,16 +420,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
                    list = list.stream()
 | 
			
		||||
                            .filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard()))
 | 
			
		||||
                            .collect(Collectors.toList());
 | 
			
		||||
                } /*else {
 | 
			
		||||
                    list = filterInfoTools(list, username);
 | 
			
		||||
                }*/
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // 根据用户名判断用户是否为班组长
 | 
			
		||||
            if (CollectionUtils.isNotEmpty(list)) {
 | 
			
		||||
                list1 = groupByThirdTypeId(list);
 | 
			
		||||
            } /*else if (CollectionUtils.isNotEmpty(totalList)) {
 | 
			
		||||
                list1 = groupByThirdTypeId(totalList);
 | 
			
		||||
            }*/
 | 
			
		||||
            }
 | 
			
		||||
            return list1;
 | 
			
		||||
        } catch (Exception e){
 | 
			
		||||
            log.error("获取设备台账列表失败,参数:{}", bean, e);
 | 
			
		||||
| 
						 | 
				
			
			@ -488,9 +489,11 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
            // 查询clz_slt_agreement_info数据
 | 
			
		||||
            List<MaterialRetainedEquipmentInfo> list = materialMachineMapper.getTeamUseNumDetailsList(bean);
 | 
			
		||||
            Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
 | 
			
		||||
            if (!CollectionUtils.isEmpty(primaryList) && deptId != null) {
 | 
			
		||||
                // 删除元素
 | 
			
		||||
                primaryList.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
 | 
			
		||||
            if (teamData == null) {
 | 
			
		||||
                if (!CollectionUtils.isEmpty(primaryList) && deptId != null) {
 | 
			
		||||
                    // 删除元素
 | 
			
		||||
                    primaryList.removeIf(m -> !deptId.toString().equals(m.getImpUnit()));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (CollectionUtils.isEmpty(primaryList)) {
 | 
			
		||||
                return new MaterialRetainedEquipmentInfo();
 | 
			
		||||
| 
						 | 
				
			
			@ -851,18 +854,13 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
        BigDecimal inRopeNum = BigDecimal.ZERO;
 | 
			
		||||
 | 
			
		||||
        // 获取在用量
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> useInfoList = materialMachineMapper.getRetainTotalInfo(bean);
 | 
			
		||||
        //List<MaterialRetainedEquipmentInfo> useInfoList = materialMachineMapper.getRetainTotalInfo(bean);
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> useInfoList = materialMachineMapper.getUsInfoList(bean);
 | 
			
		||||
        // 分别获取useInfoList中以unitValue分组的usNum数量,展示出来
 | 
			
		||||
        if (!CollectionUtils.isEmpty(useInfoList)) {
 | 
			
		||||
            // 过滤掉不在未结算工程集合内的设备
 | 
			
		||||
            Iterator<MaterialRetainedEquipmentInfo> iterator = useInfoList.iterator();
 | 
			
		||||
            while (iterator.hasNext()) {
 | 
			
		||||
                MaterialRetainedEquipmentInfo infos = iterator.next();
 | 
			
		||||
                if (infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId())) {
 | 
			
		||||
                    // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
                    iterator.remove();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
            useInfoList.removeIf(infos -> infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId()));
 | 
			
		||||
 | 
			
		||||
            useCountNum = useInfoList.stream()
 | 
			
		||||
                    .filter(item -> "0".equals(item.getUnitValue()))
 | 
			
		||||
| 
						 | 
				
			
			@ -880,40 +878,20 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
        List<MaterialRetainedEquipmentInfo> recordList = materialMachineMapper.getRetainInfoList(bean);
 | 
			
		||||
        if (CollectionUtils.isNotEmpty(recordList)) {
 | 
			
		||||
            // 过滤掉不在未结算工程集合内的设备
 | 
			
		||||
            Iterator<MaterialRetainedEquipmentInfo> iterator = recordList.iterator();
 | 
			
		||||
            while (iterator.hasNext()) {
 | 
			
		||||
                MaterialRetainedEquipmentInfo infos = iterator.next();
 | 
			
		||||
                if (infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId())) {
 | 
			
		||||
                    // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
                    iterator.remove();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
            recordList.removeIf(infos -> infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId()));
 | 
			
		||||
 | 
			
		||||
            inCountNum = recordList.stream()
 | 
			
		||||
                    .filter(item -> "0".equals(item.getUnitValue()) && !"32".equals(item.getUnitType()))
 | 
			
		||||
                    .filter(item -> "0".equals(item.getUnitValue()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
            inRopeNum = recordList.stream()
 | 
			
		||||
                    .filter(item -> "1".equals(item.getUnitValue())  && !"32".equals(item.getUnitType())   )
 | 
			
		||||
                    .filter(item -> "1".equals(item.getUnitValue()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            useCountNumSub = recordList.stream()
 | 
			
		||||
                    .filter(item -> "0".equals(item.getUnitValue())  && "32".equals(item.getUnitType()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
 | 
			
		||||
            useRopeNumSub = recordList.stream()
 | 
			
		||||
                    .filter(item -> "1".equals(item.getUnitValue()) && "32".equals(item.getUnitType()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            // 获取到recordList中externalId不为null且去重的总数(转换为Integer类型)
 | 
			
		||||
            info.setProNum((int) recordList.stream()
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getProName)
 | 
			
		||||
| 
						 | 
				
			
			@ -923,18 +901,32 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
        } else {
 | 
			
		||||
            info.setProNum(0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 查询分包商领用数据,不作为库存,作为再用数据
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> subList = materialMachineMapper.getSubInfoList(bean);
 | 
			
		||||
        if (CollectionUtils.isNotEmpty(subList)) {
 | 
			
		||||
            // 过滤掉不在未结算工程集合内的设备
 | 
			
		||||
            // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
            subList.removeIf(infos -> infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId()));
 | 
			
		||||
 | 
			
		||||
            useCountNumSub = subList.stream()
 | 
			
		||||
                    .filter(item -> "0".equals(item.getUnitValue()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
 | 
			
		||||
            useRopeNumSub = subList.stream()
 | 
			
		||||
                    .filter(item -> "1".equals(item.getUnitValue()))
 | 
			
		||||
                    .map(MaterialRetainedEquipmentInfo::getAllNum)
 | 
			
		||||
                    .reduce(BigDecimal::add)
 | 
			
		||||
                    .orElse(BigDecimal.ZERO);
 | 
			
		||||
        }
 | 
			
		||||
        // 查询目前在用的设备信息
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> usList = materialMachineMapper.getUsInfoList(bean);
 | 
			
		||||
        if (CollectionUtils.isNotEmpty(usList)) {
 | 
			
		||||
            // 过滤掉不在未结算工程集合内的设备
 | 
			
		||||
            Iterator<MaterialRetainedEquipmentInfo> iterator = usList.iterator();
 | 
			
		||||
            while (iterator.hasNext()) {
 | 
			
		||||
                MaterialRetainedEquipmentInfo infos = iterator.next();
 | 
			
		||||
                if (infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId())) {
 | 
			
		||||
                    // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
                    iterator.remove();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // 如果 proId 不在未结算集合中,则移除
 | 
			
		||||
            usList.removeIf(infos -> infos.getProId() == null || !unsettledProjectIds.contains(infos.getProId()));
 | 
			
		||||
 | 
			
		||||
            // 获取usList中的班组id,且去重的数量
 | 
			
		||||
            info.setTeamNum((int) usList.stream()
 | 
			
		||||
| 
						 | 
				
			
			@ -1148,7 +1140,11 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
            // 部门查询赋值
 | 
			
		||||
            extractedDept(bean);
 | 
			
		||||
        }
 | 
			
		||||
        return materialMachineMapper.getTeamList(bean);
 | 
			
		||||
        MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo = new MaterialRetainedEquipmentInfo();
 | 
			
		||||
        materialRetainedEquipmentInfo.setTeamName("站内库存");
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> teamList = materialMachineMapper.getTeamList(bean);
 | 
			
		||||
        teamList.add(0, materialRetainedEquipmentInfo);
 | 
			
		||||
        return teamList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -1175,7 +1171,11 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
 | 
			
		|||
            // 部门查询赋值
 | 
			
		||||
            extractedDept(bean);
 | 
			
		||||
        }
 | 
			
		||||
        return materialMachineMapper.getSubUnitList(bean);
 | 
			
		||||
        MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo = new MaterialRetainedEquipmentInfo();
 | 
			
		||||
        materialRetainedEquipmentInfo.setSubUnitName("分包直领");
 | 
			
		||||
        List<MaterialRetainedEquipmentInfo> list = materialMachineMapper.getSubUnitList(bean);
 | 
			
		||||
        list.add(0, materialRetainedEquipmentInfo);
 | 
			
		||||
        return list;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -346,6 +346,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        sai.status = '0'
 | 
			
		||||
        AND sai.end_time IS NULL
 | 
			
		||||
        AND sai.back_id IS NULL
 | 
			
		||||
        AND sai.ma_id IS NOT NULL
 | 
			
		||||
        <if test="typeId != null">
 | 
			
		||||
            and mt2.type_id = #{typeId}
 | 
			
		||||
        </if>
 | 
			
		||||
| 
						 | 
				
			
			@ -1321,8 +1322,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        '数量'
 | 
			
		||||
        END                                manageType,
 | 
			
		||||
        subquery1.teamName  AS teamName,
 | 
			
		||||
        subquery1.unitType as unitType,
 | 
			
		||||
        IF( subquery1.unitType= 32,"机具分包领用",'/' )AS subUnitName,
 | 
			
		||||
        '/' AS subUnitName,
 | 
			
		||||
        mt.unit_value  AS unitValue,
 | 
			
		||||
        CASE mt.jiju_type
 | 
			
		||||
        WHEN 2 THEN
 | 
			
		||||
| 
						 | 
				
			
			@ -1349,8 +1349,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
                bu.bzz_idcard AS idCard,
 | 
			
		||||
                df.project_dept AS proCenter,
 | 
			
		||||
                sd.dept_name AS departName,
 | 
			
		||||
        bu.type_id AS unitType,
 | 
			
		||||
                if(bu.type_id=32,bu.unit_name,'站内库存' )    AS  teamName
 | 
			
		||||
                '站内库存'     AS  teamName
 | 
			
		||||
            FROM
 | 
			
		||||
                slt_agreement_info sai
 | 
			
		||||
                    LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
 | 
			
		||||
| 
						 | 
				
			
			@ -1369,6 +1368,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
              AND sai.end_time IS NULL
 | 
			
		||||
              AND sai.back_id IS NULL
 | 
			
		||||
              AND bp.external_id IS NOT NULL
 | 
			
		||||
              AND bu.type_id = 36
 | 
			
		||||
        <if test="impUnitName != null and impUnitName != ''">
 | 
			
		||||
            AND sd.dept_name like concat('%',#{impUnitName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
| 
						 | 
				
			
			@ -1387,6 +1387,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        <if test="teamName != null and teamName != ''">
 | 
			
		||||
            AND '站内库存' like concat('%',#{teamName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
        <if test="subUnitName != null and subUnitName != ''">
 | 
			
		||||
            AND '站内库存' like concat('%',#{subUnitName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
        <if test="projectIdList != null  and projectIdList.size() > 0">
 | 
			
		||||
            and bp.external_id  in
 | 
			
		||||
            <foreach item="item" collection="projectIdList" open="(" separator="," close=")">
 | 
			
		||||
| 
						 | 
				
			
			@ -1452,6 +1455,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        <if test="teamName != null and teamName != ''">
 | 
			
		||||
            AND '站内库存' like concat('%',#{teamName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
        <if test="subUnitName != null and subUnitName != ''">
 | 
			
		||||
            AND '站内库存' like concat('%',#{subUnitName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
        <if test="typeModelName != null and typeModelName != ''">
 | 
			
		||||
            AND mt.type_name like concat('%',#{typeModelName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
| 
						 | 
				
			
			@ -2303,4 +2309,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        lpd.project_id,
 | 
			
		||||
        lpd.type_id
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="getSubInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
 | 
			
		||||
        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 allNum,
 | 
			
		||||
        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 departName,
 | 
			
		||||
        sd.dept_name AS impUnitName,
 | 
			
		||||
        bu.unit_name  AS  teamName,
 | 
			
		||||
        '分包直领'  AS subUnitName,
 | 
			
		||||
        mt.unit_name AS unit,
 | 
			
		||||
        mt.unit_value  AS unitValue,
 | 
			
		||||
        CASE mt.jiju_type
 | 
			
		||||
        WHEN 2 THEN
 | 
			
		||||
        '安全工器具'
 | 
			
		||||
        ELSE
 | 
			
		||||
        '施工机具'
 | 
			
		||||
        END                                jiJuType
 | 
			
		||||
        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
 | 
			
		||||
        AND bu.type_id = 32
 | 
			
		||||
        <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>
 | 
			
		||||
        <if test="subUnitName != null and subUnitName != ''">
 | 
			
		||||
            AND '分包直领' like concat('%',#{subUnitName},'%')
 | 
			
		||||
        </if>
 | 
			
		||||
        GROUP BY
 | 
			
		||||
        mt.type_id,
 | 
			
		||||
        bp.pro_id
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue