package com.ruoyi.zdsz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.DynamicName;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.handler.MonthTableNameHandler;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.zdsz.domain.*;
import com.ruoyi.zdsz.domain.bo.ZEngineeringInfoBo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringMaterialBo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringReviewBo;
import com.ruoyi.zdsz.domain.vo.ZEngineeringCivilVo;
import com.ruoyi.zdsz.domain.vo.ZEngineeringInfoVo;
import com.ruoyi.zdsz.enums.photoType;
import com.ruoyi.zdsz.mapper.*;
import com.ruoyi.zdsz.service.*;
import lombok.RequiredArgsConstructor;
import org.hibernate.validator.internal.util.stereotypes.Lazy;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 工程详情Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@RequiredArgsConstructor
@Service
public class ZEngineeringInfoServiceImpl implements IZEngineeringInfoService {

    private final ZEngineeringInfoMapper baseMapper;
    @Resource
    private ZEngineeringCivilMapper zEngineeringCivilMapper;
    @Resource
    private IZEngineeringMaterialService izEngineeringMaterialService;
    @Resource
    private IZEngiineeringPhotoService izEngiineeringPhotoService;
    @Resource
    private ISysUserService sysUserService;
    @Resource
    private IZEngineeringReviewService izEngineeringReviewService;
    @Resource
    private ZEngineeringNodeMapper zEngineeringNodeMapper;
    @Resource
    private ZEngineeringMaterialMapper zEngineeringMaterialMapper;
    @Resource
    private final ZMaterialStatisticsMapper zMaterialStatisticsMapper;

    /**
     * 查询工程详情
     */
    @Override
    public ZEngineeringInfoVo queryById(String id) {
        return baseMapper.selectVoById(id);
    }

    @Override
    @DynamicName(spel = "#bo.createTime")
    public List<ZEngineeringInfoBo> query(ZEngineeringNodeBo bo) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.orderByDesc(ZEngineeringInfo::getUpdateTime);
        List<ZEngineeringInfo> zEngineeringInfoVoList = baseMapper.selectList(lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getEngInfoId, bo.getId()));
        List<ZEngineeringInfoBo> zEngineeringInfoBoList = new ArrayList<>();
        zEngineeringInfoVoList.stream().forEach(item -> {
            ZEngineeringInfoBo zEngineeringInfoBo1 = BeanUtil.toBean(item, ZEngineeringInfoBo.class);
            SysUser sysUser = sysUserService.selectUserById(Long.parseLong(item.getConstructUser()));
            if (!ObjectUtils.isEmpty(sysUser)) {
                zEngineeringInfoBo1.setHeadName(sysUser.getNickName());
                zEngineeringInfoBo1.setConstructUser(sysUser.getNickName());
                zEngineeringInfoBo1.setHeadPhone(sysUser.getPhonenumber());
                zEngineeringInfoBo1.setConstructPhone(sysUser.getPhonenumber());
            }
            List<String> photoList = izEngiineeringPhotoService.queryList(zEngineeringInfoBo1);
            List<ZEngineeringMaterialBo> zEngineeringMaterialBo = izEngineeringMaterialService.query(zEngineeringInfoBo1);
            zEngineeringInfoBo1.setzEngiineeringPhotoBoList(photoList);
            zEngineeringInfoBo1.setzEngineeringMaterialBo(zEngineeringMaterialBo);
            zEngineeringInfoBo1.setBoxBrand(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.boxBrand.name()));
            zEngineeringInfoBo1.setLightning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.Lightning.name()));
            zEngineeringInfoBo1.setBottomLeg(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.BottomLeg.name()));
            zEngineeringInfoBo1.setGroundHardening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.GroundHardening.name()));
            zEngineeringInfoBo1.setPhotosAfter(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.photosAfter.name()));
            zEngineeringInfoBo1.setStonePowder(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.stonePowder.name()));
            zEngineeringInfoBo1.setDuctalEpithelium(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ductalEpithelium.name()));
            zEngineeringInfoBo1.setWarningtTape(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.warningtTape.name()));
            zEngineeringInfoBo1.setVideo(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.Video.name()));
            zEngineeringInfoBo1.setTrenchProspect(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.trenchProspect.name()));
            zEngineeringInfoBo1.setBeforeBottom(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.beforeBottom.name()));
            zEngineeringInfoBo1.setLegBackfilling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.legBackfilling.name()));
            zEngineeringInfoBo1.setInferiorSulcus(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.inferiorSulcus.name()));
            zEngineeringInfoBo1.setConstructionRecords(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.constructionRecords.name()));
            zEngineeringInfoBo1.setOnTheDitch(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.onTheDitch.name()));
            // 市政施工-查询 start
            zEngineeringInfoBo1.setzEngiineeringPhotoBoListOne(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.beforeBack.name()));
            zEngineeringInfoBo1.setzEngiineeringPhotoBoListTwo(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.warnBack.name()));
            zEngineeringInfoBo1.setzEngiineeringPhotoBoListThree(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.afterBack.name()));
            // 市政施工-查询 end

            // 带气封堵施工-查询 start
            zEngineeringInfoBo1.setPeSaddleWelding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peSaddleWelding.name()));
            zEngineeringInfoBo1.setPeAirtightTest(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peAirtightTest.name()));
            zEngineeringInfoBo1.setPeHolesOpening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peHolesOpening.name()));
            zEngineeringInfoBo1.setPeCleaning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peCleaning.name()));
            zEngineeringInfoBo1.setPePlugging(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.pePlugging.name()));
            zEngineeringInfoBo1.setPeCollisionOperating(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peCollisionOperating.name()));
            zEngineeringInfoBo1.setPeAirrecovering(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peAirrecovering.name()));
            zEngineeringInfoBo1.setPeHomeworkDone(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peHomeworkDone.name()));

            zEngineeringInfoBo1.setIronPipelineThickness(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironPipelineThickness.name()));
            zEngineeringInfoBo1.setIron4Welding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.iron4Welding.name()));
            zEngineeringInfoBo1.setIronBypassWelding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironBypassWelding.name()));
            zEngineeringInfoBo1.setIronHolesOpening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironHolesOpening.name()));
            zEngineeringInfoBo1.setIronCleaning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironCleaning.name()));
            zEngineeringInfoBo1.setIronNitrogenPurging(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironNitrogenPurging.name()));
            zEngineeringInfoBo1.setIronPipelineReplacing(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironPipelineReplacing.name()));
            zEngineeringInfoBo1.setIronLowerEndCap(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironLowerEndCap.name()));
            zEngineeringInfoBo1.setIronHomeworkDone(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironHomeworkDone.name()));
            zEngineeringInfoBo1.setIron4Aczoiling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.iron4Aczoiling.name()));
            // 市政施工-查询 end

            // bo.setId(item.getId());
            ZEngineeringReviewBo zEngineeringReviewbo = izEngineeringReviewService.query(bo);
            zEngineeringInfoBo1.setzEngineeringReviewBo(zEngineeringReviewbo);
            zEngineeringInfoBoList.add(zEngineeringInfoBo1);
        });

        return zEngineeringInfoBoList;
    }
    @Override
    @DynamicName(spel = "#bo.createTime")
    public List<ZEngineeringInfoBo> queryInsert(ZEngineeringNodeBo bo) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.orderByDesc(ZEngineeringInfo::getUpdateTime);
        List<ZEngineeringInfo> zEngineeringInfoVoList = baseMapper.selectList(lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getEngInfoId, bo.getId()));
        List<ZEngineeringInfoBo> zEngineeringInfoBoList = new ArrayList<>();
        zEngineeringInfoVoList.stream().forEach(item -> {
            ZEngineeringInfoBo zEngineeringInfoBo1 = BeanUtil.toBean(item, ZEngineeringInfoBo.class);
            SysUser sysUser = sysUserService.selectUserById(Long.parseLong(item.getConstructUser()));
            if (!ObjectUtils.isEmpty(sysUser)) {
                zEngineeringInfoBo1.setHeadName(sysUser.getNickName());
                zEngineeringInfoBo1.setConstructUser(sysUser.getNickName());
                zEngineeringInfoBo1.setHeadPhone(sysUser.getPhonenumber());
                zEngineeringInfoBo1.setConstructPhone(sysUser.getPhonenumber());
            }
            List<String> photoList = izEngiineeringPhotoService.queryInsertList(zEngineeringInfoBo1);
            List<ZEngineeringMaterialBo> zEngineeringMaterialBo = izEngineeringMaterialService.query(zEngineeringInfoBo1);
            zEngineeringInfoBo1.setzEngiineeringPhotoBoList(photoList);
            zEngineeringInfoBo1.setzEngineeringMaterialBo(zEngineeringMaterialBo);
            zEngineeringInfoBo1.setBoxBrand(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.boxBrand.name()));
            zEngineeringInfoBo1.setLightning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.Lightning.name()));
            zEngineeringInfoBo1.setBottomLeg(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.BottomLeg.name()));
            zEngineeringInfoBo1.setGroundHardening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.GroundHardening.name()));
            zEngineeringInfoBo1.setPhotosAfter(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.photosAfter.name()));
            zEngineeringInfoBo1.setStonePowder(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.stonePowder.name()));
            zEngineeringInfoBo1.setDuctalEpithelium(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ductalEpithelium.name()));
            zEngineeringInfoBo1.setWarningtTape(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.warningtTape.name()));
            zEngineeringInfoBo1.setVideo(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.Video.name()));
            zEngineeringInfoBo1.setTrenchProspect(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.trenchProspect.name()));
            zEngineeringInfoBo1.setBeforeBottom(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.beforeBottom.name()));
            zEngineeringInfoBo1.setLegBackfilling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.legBackfilling.name()));
            zEngineeringInfoBo1.setInferiorSulcus(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.inferiorSulcus.name()));
            zEngineeringInfoBo1.setConstructionRecords(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.constructionRecords.name()));
            zEngineeringInfoBo1.setOnTheDitch(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.onTheDitch.name()));
            // bo.setId(item.getId());
            // 批量审核 start
            // 市政施工-查询 start
            zEngineeringInfoBo1.setWelding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.welding.name()));
            zEngineeringInfoBo1.setAczoiling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.aczoiling.name()));
            zEngineeringInfoBo1.setPiping(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.piping.name()));
            zEngineeringInfoBo1.setWarning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.warning.name()));
            zEngineeringInfoBo1.setBackfilling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.backfilling.name()));
            // 市政施工-查询 end

            // 带气封堵施工-查询 start
            zEngineeringInfoBo1.setPeSaddleWelding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peSaddleWelding.name()));
            zEngineeringInfoBo1.setPeAirtightTest(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peAirtightTest.name()));
            zEngineeringInfoBo1.setPeHolesOpening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peHolesOpening.name()));
            zEngineeringInfoBo1.setPeCleaning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peCleaning.name()));
            zEngineeringInfoBo1.setPePlugging(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.pePlugging.name()));
            zEngineeringInfoBo1.setPeCollisionOperating(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peCollisionOperating.name()));
            zEngineeringInfoBo1.setPeAirrecovering(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peAirrecovering.name()));
            zEngineeringInfoBo1.setPeHomeworkDone(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.peHomeworkDone.name()));

            zEngineeringInfoBo1.setIronPipelineThickness(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironPipelineThickness.name()));
            zEngineeringInfoBo1.setIron4Welding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.iron4Welding.name()));
            zEngineeringInfoBo1.setIronBypassWelding(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironBypassWelding.name()));
            zEngineeringInfoBo1.setIronHolesOpening(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironHolesOpening.name()));
            zEngineeringInfoBo1.setIronCleaning(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironCleaning.name()));
            zEngineeringInfoBo1.setIronNitrogenPurging(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironNitrogenPurging.name()));
            zEngineeringInfoBo1.setIronPipelineReplacing(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironPipelineReplacing.name()));
            zEngineeringInfoBo1.setIronLowerEndCap(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironLowerEndCap.name()));
            zEngineeringInfoBo1.setIronHomeworkDone(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.ironHomeworkDone.name()));
            zEngineeringInfoBo1.setIron4Aczoiling(izEngiineeringPhotoService.queryTypeList(zEngineeringInfoBo1,photoType.iron4Aczoiling.name()));
            // 市政施工-查询 end
            // 批量审核 end

            ZEngineeringReviewBo zEngineeringReviewbo = izEngineeringReviewService.query(bo);
            zEngineeringInfoBo1.setzEngineeringReviewBo(zEngineeringReviewbo);
            zEngineeringInfoBoList.add(zEngineeringInfoBo1);
        });

        return zEngineeringInfoBoList;
    }

    /**
     *
     */
    @Override
    public TableDataInfo<ZEngineeringInfoVo> queryPageList(ZEngineeringInfoBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = buildQueryWrapper(bo);
        Page<ZEngineeringInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询工程详情列表
     */
    @Override
    public List<ZEngineeringInfoVo> queryList(ZEngineeringInfoBo bo) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<ZEngineeringInfo> buildQueryWrapper(ZEngineeringInfoBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getEngInfoId()), ZEngineeringInfo::getEngInfoId, bo.getEngInfoId());
        lqw.eq(StringUtils.isNotBlank(bo.getConstructAddre()), ZEngineeringInfo::getConstructAddre, bo.getConstructAddre());
        lqw.eq(StringUtils.isNotBlank(bo.getConstructAccordingDrawings()), ZEngineeringInfo::getConstructAccordingDrawings, bo.getConstructAccordingDrawings());
        lqw.eq(StringUtils.isNotBlank(bo.getSegmentedCompressionQualified()), ZEngineeringInfo::getSegmentedCompressionQualified, bo.getSegmentedCompressionQualified());
        lqw.eq(bo.getBackfillTime() != null, ZEngineeringInfo::getBackfillTime, bo.getBackfillTime());
        lqw.eq(StringUtils.isNotBlank(bo.getConstructPhone()), ZEngineeringInfo::getConstructPhone, bo.getConstructPhone());
        lqw.eq(StringUtils.isNotBlank(bo.getConstructUser()), ZEngineeringInfo::getConstructUser, bo.getConstructUser());
        lqw.eq(bo.getConstructTime() != null, ZEngineeringInfo::getConstructTime, bo.getConstructTime());
        lqw.like(StringUtils.isNotBlank(bo.getHeadName()), ZEngineeringInfo::getHeadName, bo.getHeadName());
        lqw.eq(StringUtils.isNotBlank(bo.getHeadPhone()), ZEngineeringInfo::getHeadPhone, bo.getHeadPhone());
        return lqw;
    }

    /**
     * 新增工程详情
     */
    @Override
    public Boolean insertByBo(ZEngineeringInfoBo bo) {
        ZEngineeringInfo add = BeanUtil.toBean(bo, ZEngineeringInfo.class);
        validEntityBeforeSave(add);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setId(add.getId());
        }
        return flag;
    }


    /**
     * 新增工程详情(节点使用)
     *
     * @param bo
     * @return ZEngineeringInfo
     */
    @Override
    @DynamicName(spel = "#bo.createTime")
    @Transactional(rollbackFor = Exception.class)

    public ZEngineeringInfo insert(ZEngineeringInfoBo bo) {
        ZEngineeringInfo add = BeanUtil.toBean(bo, ZEngineeringInfo.class);
        validEntityBeforeSave(add);
        add.setConstructUser(String.valueOf(LoginHelper.getLoginUser().getUserId()));
        add.setHeadName(String.valueOf(LoginHelper.getLoginUser().getUserId()));
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setId(add.getId());
        }
        if (bo.getzEngineeringMaterialBo()!=null&& !bo.getzEngineeringMaterialBo().isEmpty())
        {
        bo.getzEngineeringMaterialBo().stream().forEach(item->{
            item.setDetailsId(add.getId());
            item.setCreateTime(bo.getCreateTime());
            item.setUpdateTime(new Date());
            izEngineeringMaterialService.insert(item);
        });
        }
        List<ZEngiineeringPhoto> photoList = new ArrayList<>();
        if (!ObjectUtils.isEmpty(bo.getPhotosAfter()))
        {
            bo.getPhotosAfter().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.photosAfter.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getBoxBrand()))
        {
            bo.getBoxBrand().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.boxBrand.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListOne()))
        {
            bo.getzEngiineeringPhotoBoListOne().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.beforeBack.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListTwo()))
        {
            bo.getzEngiineeringPhotoBoListTwo().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.warnBack.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListThree()))
        {
            bo.getzEngiineeringPhotoBoListThree().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.afterBack.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getLightning()))
        {
            bo.getLightning().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.Lightning.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getBottomLeg()))
        {
            bo.getBottomLeg().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.BottomLeg.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getGroundHardening()))
        {
            bo.getGroundHardening().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.GroundHardening.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getOnTheDitch()))
        {
            bo.getOnTheDitch().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.onTheDitch.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getBeforeBottom()))
        {
            bo.getBeforeBottom().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.beforeBottom.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getConstructionRecords()))
        {
            bo.getConstructionRecords().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.constructionRecords.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }

        if (!ObjectUtils.isEmpty(bo.getLegBackfilling()))
        {
            bo.getLegBackfilling().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.legBackfilling.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getInferiorSulcus()))
        {
            bo.getInferiorSulcus().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.inferiorSulcus.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getVideo()))
        {

            bo.getVideo().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.Video.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getDuctalEpithelium()))
        {

            bo.getDuctalEpithelium().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ductalEpithelium.name().toString());
                photoList.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getStonePowder()))
        {

            bo.getStonePowder().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.stonePowder.name().toString());
                photoList.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getTrenchProspect()))
        {

            bo.getTrenchProspect().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.trenchProspect.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getWarningtTape()))
        {

            bo.getWarningtTape().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.warningtTape.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoList())) {
            bo.getzEngiineeringPhotoBoList().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                photoList.add(zEngiineeringPhoto);
            });

        }
        // 市政施工-插入 start
        /*
            // 市政施工-沟上施工 焊接
            welding,
            // 市政施工-沟上施工 防腐
            aczoiling,
            // 市政施工-沟下施工 管道下沟
            piping,
            // 市政施工-沟下施工 警示带铺设
            warning,
            // 市政施工-沟下施工 回填
            backfilling
        */
        if (!ObjectUtils.isEmpty(bo.getWelding())) {
            bo.getWelding().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.welding.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getAczoiling())) {
            bo.getAczoiling().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.aczoiling.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPiping())) {
            bo.getPiping().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.piping.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getWarning())) {
            bo.getWarning().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.warning.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getBackfilling())) {
            bo.getBackfilling().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.backfilling.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        // 市政施工-插入 end
        // 带气封堵施工--插入 start
        if (!ObjectUtils.isEmpty(bo.getPeSaddleWelding())) {
            bo.getPeSaddleWelding().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peSaddleWelding.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeAirtightTest())) {
            bo.getPeAirtightTest().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peAirtightTest.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeHolesOpening())) {
            bo.getPeHolesOpening().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peHolesOpening.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeCleaning())) {
            bo.getPeCleaning().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peCleaning.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPePlugging())) {
            bo.getPePlugging().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.pePlugging.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeCollisionOperating())) {
            bo.getPeCollisionOperating().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peCollisionOperating.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeAirrecovering())) {
            bo.getPeAirrecovering().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peAirrecovering.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getPeHomeworkDone())) {
            bo.getPeHomeworkDone().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.peHomeworkDone.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }

        if (!ObjectUtils.isEmpty(bo.getIronPipelineThickness())) {
            bo.getIronPipelineThickness().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironPipelineThickness.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIron4Welding())) {
            bo.getIron4Welding().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.iron4Welding.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronBypassWelding())) {
            bo.getIronBypassWelding().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironBypassWelding.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronHolesOpening())) {
            bo.getIronHolesOpening().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironHolesOpening.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronCleaning())) {
            bo.getIronCleaning().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironCleaning.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronNitrogenPurging())) {
            bo.getIronNitrogenPurging().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironNitrogenPurging.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronPipelineReplacing())) {
            bo.getIronPipelineReplacing().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironPipelineReplacing.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronLowerEndCap())) {
            bo.getIronLowerEndCap().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironLowerEndCap.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIronHomeworkDone())) {
            bo.getIronHomeworkDone().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ironHomeworkDone.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getIron4Aczoiling())) {
            bo.getIron4Aczoiling().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.iron4Aczoiling.name().toString());
                photoList.add(zEngiineeringPhoto);
            });
        }
        // 带气封堵施工--插入 end

        if (!photoList.isEmpty()) {
            izEngiineeringPhotoService.insertBatch(photoList);
        }
        return add;
    }

    /**
     * 修改工程详情
     */
    @Override
    public Boolean updateByBo(ZEngineeringInfoBo bo) {
        ZEngineeringInfo update = BeanUtil.toBean(bo, ZEngineeringInfo.class);
        validEntityBeforeSave(update);
        return baseMapper.updateById(update) > 0;
    }

    @Override
    @DynamicName(spel = "#bo.createTime")
    public Boolean update(ZEngineeringInfoBo bo) {
        bo.setHeadName(LoginHelper.getLoginUser().getUserId().toString());
        bo.setConstructUser(LoginHelper.getLoginUser().getUserId().toString());

        ZEngineeringInfo update = BeanUtil.toBean(bo, ZEngineeringInfo.class);
        validEntityBeforeSave(update);
        List<ZEngiineeringPhoto> photoList = new ArrayList();
        bo.getzEngiineeringPhotoBoList().stream().forEach(item -> {
            ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
            zEngiineeringPhoto.setParentId(update.getId());
            zEngiineeringPhoto.setPicUrl(item);
            zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
           // zEngiineeringPhoto.setUpdateTime(new Date());
            photoList.add(zEngiineeringPhoto);
        });
        if (photoList.size() > 0 ) {
            izEngiineeringPhotoService.updateBatch(photoList);
        }
        List<ZEngiineeringPhoto> photoList2 = new ArrayList<>();
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListOne()))
        {
            bo.getzEngiineeringPhotoBoListOne().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.beforeBack.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListTwo()))
        {
            bo.getzEngiineeringPhotoBoListTwo().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.warnBack.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getzEngiineeringPhotoBoListThree()))
        {
            bo.getzEngiineeringPhotoBoListThree().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.afterBack.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });
        }
        if (!ObjectUtils.isEmpty(bo.getConstructionRecords()))
        {
            bo.getConstructionRecords().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.constructionRecords.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getBoxBrand()))
        {
            bo.getBoxBrand().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.boxBrand.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getLightning()))
        {
            bo.getLightning().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.Lightning.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getBottomLeg()))
        {
            bo.getBottomLeg().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.BottomLeg.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getGroundHardening()))
        {
            bo.getGroundHardening().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.GroundHardening.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getOnTheDitch()))
        {
            bo.getOnTheDitch().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.onTheDitch.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });
        }

        if (!ObjectUtils.isEmpty(bo.getInferiorSulcus()))
        {
            bo.getInferiorSulcus().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.inferiorSulcus.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getLegBackfilling()))
        {
            bo.getLegBackfilling().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.legBackfilling.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (!ObjectUtils.isEmpty(bo.getPhotosAfter()))
        {

            bo.getPhotosAfter().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setType(photoType.photosAfter.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getWarningtTape()))
        {

            bo.getWarningtTape().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setType(photoType.warningtTape.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getVideo()))
        {

            bo.getVideo().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.Video.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getDuctalEpithelium()))
        {

            bo.getDuctalEpithelium().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.ductalEpithelium.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getStonePowder()))
        {

            bo.getStonePowder().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.stonePowder.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getTrenchProspect()))
        {

            bo.getTrenchProspect().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(update.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.trenchProspect.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });

        }
        if (!ObjectUtils.isEmpty(bo.getBeforeBottom()))
        {
            bo.getBeforeBottom().forEach(item -> {
                ZEngiineeringPhoto zEngiineeringPhoto = new ZEngiineeringPhoto();
                zEngiineeringPhoto.setParentId(bo.getId());
                zEngiineeringPhoto.setPicUrl(item);
                zEngiineeringPhoto.setCreateTime(bo.getCreateTime());
                zEngiineeringPhoto.setUpdateTime(new Date());
                zEngiineeringPhoto.setType(photoType.beforeBottom.name().toString());
                photoList2.add(zEngiineeringPhoto);
            });


        }
        if (photoList2.size() > 0 ) {
            izEngiineeringPhotoService.updateBatch(photoList2);
        }
        izEngineeringMaterialService.updateList(bo);
       // update.setUpdateTime(new Date());
        SimpleDateFormat format =new SimpleDateFormat("yyyy_MM");
        MonthTableNameHandler.setData(format.format(bo.getCreateTime()));

         Boolean FLAG=  baseMapper.updateById(update) > 0;
        MonthTableNameHandler.removeData();
        return FLAG;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ZEngineeringInfo entity) {
        //TODO 做一些数据校验,如唯一约束
    }

    /**
     * 批量删除工程详情
     */
    @Override
    public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
        if (isValid) {
            //TODO 做一些业务上的校验,判断是否需要校验
        }
        return baseMapper.deleteBatchIds(ids) > 0;
    }

    @Override
    @DynamicName(spel = "#bo.createTime")
    @Transactional(rollbackFor = Exception.class)
    public Boolean delete(ZEngineeringNodeBo bo) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getEngInfoId, bo.getId());
        List<ZEngineeringInfo> zEngineeringInfo = baseMapper.selectList(lqw);
        zEngineeringInfo.stream().forEach(item -> {
            ZEngineeringInfoBo zEngineeringInfobo = BeanUtil.toBean(item, ZEngineeringInfoBo.class);
            izEngiineeringPhotoService.delete(zEngineeringInfobo);
            izEngineeringMaterialService.delete(zEngineeringInfobo);
            baseMapper.deleteById(item.getId());
        });
        return null;
    }

    @Override
    @DynamicName(spel = "#bo.createTime")
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteById(ZEngineeringInfoBo bo) {
      ZEngineeringInfo zEngineeringInfo2=  baseMapper.selectById(bo.getId());
      ZEngineeringNode zEngineeringNode=zEngineeringNodeMapper.selectById(zEngineeringInfo2.getEngInfoId());
       ZEngineeringCivil zEngineeringCivil=zEngineeringCivilMapper.selectById(zEngineeringNode.getCivliId());
        LambdaQueryWrapper<ZEngineeringMaterial> lqw3 = Wrappers.lambdaQuery();
        lqw3.eq(ZEngineeringMaterial::getDetailsId,zEngineeringInfo2.getId());
        List<ZEngineeringMaterial> zEngineeringMaterialList= zEngineeringMaterialMapper.selectList(lqw3);
        zEngineeringMaterialList.stream().forEach(item->{
        LambdaQueryWrapper<ZMaterialStatistics> lqwstatis = Wrappers.lambdaQuery();
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getAreaId()), ZMaterialStatistics::getAreaId, zEngineeringCivil.getAreaId());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getBuildingId()), ZMaterialStatistics::getBuildingId, zEngineeringCivil.getBuildingId());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getUnitId()), ZMaterialStatistics::getUnitId, zEngineeringCivil.getUnitId());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getHouseId()), ZMaterialStatistics::getHouseId, zEngineeringCivil.getHouseId());
        lqwstatis.eq(StringUtils.isNotBlank(item.getMaterialQuality()), ZMaterialStatistics::getRealityQuality, item.getMaterialQuality());
        lqwstatis.eq(StringUtils.isNotBlank(item.getSpecifications()), ZMaterialStatistics::getRealitySpecifications, item.getSpecifications());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginCycle()), ZMaterialStatistics::getEnginCycle, zEngineeringCivil.getEnginCycle());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginClassification()), ZMaterialStatistics::getEnginClassification, zEngineeringCivil.getEnginClassification());
        lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginType()), ZMaterialStatistics::getEnginType, zEngineeringCivil.getEnginType());
        //lqwstatis.eq(StringUtils.isNotBlank(zEngineeringNode.getType()), ZMaterialStatistics::getNodeType, zEngineeringNode.getType());

            if(StringUtils.isNotBlank(item.getMaterialQuality())||StringUtils.isNotBlank(item.getSpecifications()))
        {
            ZMaterialStatistics zMaterialStatistics = zMaterialStatisticsMapper.selectOne(lqwstatis);


        if (!ObjectUtils.isEmpty(zMaterialStatistics)) {
            zMaterialStatistics.setRealitySize(BigDecimal.valueOf(zMaterialStatistics.getRealitySize()).subtract(BigDecimal.valueOf(item.getNumber())).doubleValue());
            zMaterialStatisticsMapper.updateById(zMaterialStatistics);
        }
        }
        });
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getId, bo.getId());
        ZEngineeringInfo zEngineeringInfo = baseMapper.selectOne(lqw);
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy_MM");
        ZEngineeringInfoBo zEngineeringInfobo = new ZEngineeringInfoBo();
        zEngineeringInfobo = BeanUtil.toBean(zEngineeringInfo, ZEngineeringInfoBo.class);
        izEngiineeringPhotoService.delete(zEngineeringInfobo);
        izEngineeringMaterialService.delete(zEngineeringInfobo);

        MonthTableNameHandler.setData(simpleDateFormat.format(bo.getCreateTime()));
        baseMapper.deleteById(bo.getId());

        LambdaQueryWrapper<ZEngineeringInfo> lqw2 = Wrappers.lambdaQuery();
        lqw2.eq(StringUtils.isNotBlank(bo.getEngInfoId()), ZEngineeringInfo::getEngInfoId, bo.getEngInfoId());
        List<ZEngineeringInfo> zEngineeringInfoList = baseMapper.selectList(lqw2);
        MonthTableNameHandler.removeData();
        if (zEngineeringInfoList.size()==0)
        {
            izEngineeringReviewService.deleteByNodeId(zEngineeringInfobo);
        }
        return null;
    }

    @Override
    @DynamicName(spel = "#bo.createTime")
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteByIdNoDelFiles(ZEngineeringInfoBo bo) {
        ZEngineeringInfo zEngineeringInfo2=  baseMapper.selectById(bo.getId());
        ZEngineeringNode zEngineeringNode=zEngineeringNodeMapper.selectById(zEngineeringInfo2.getEngInfoId());
        ZEngineeringCivil zEngineeringCivil=zEngineeringCivilMapper.selectById(zEngineeringNode.getCivliId());
        LambdaQueryWrapper<ZEngineeringMaterial> lqw3 = Wrappers.lambdaQuery();
        lqw3.eq(ZEngineeringMaterial::getDetailsId,zEngineeringInfo2.getId());
        List<ZEngineeringMaterial> zEngineeringMaterialList= zEngineeringMaterialMapper.selectList(lqw3);
        zEngineeringMaterialList.stream().forEach(item->{
            LambdaQueryWrapper<ZMaterialStatistics> lqwstatis = Wrappers.lambdaQuery();
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getAreaId()), ZMaterialStatistics::getAreaId, zEngineeringCivil.getAreaId());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getBuildingId()), ZMaterialStatistics::getBuildingId, zEngineeringCivil.getBuildingId());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getUnitId()), ZMaterialStatistics::getUnitId, zEngineeringCivil.getUnitId());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getHouseId()), ZMaterialStatistics::getHouseId, zEngineeringCivil.getHouseId());
            lqwstatis.eq( ZMaterialStatistics::getRealityQuality, item.getMaterialQuality());
            lqwstatis.eq( ZMaterialStatistics::getRealitySpecifications, item.getSpecifications());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginCycle()), ZMaterialStatistics::getEnginCycle, zEngineeringCivil.getEnginCycle());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginClassification()), ZMaterialStatistics::getEnginClassification, zEngineeringCivil.getEnginClassification());
            lqwstatis.eq(StringUtils.isNotBlank(zEngineeringCivil.getEnginType()), ZMaterialStatistics::getEnginType, zEngineeringCivil.getEnginType());
            //lqwstatis.eq(StringUtils.isNotBlank(zEngineeringNode.getType()), ZMaterialStatistics::getNodeType, zEngineeringNode.getType());
            ZMaterialStatistics zMaterialStatistics = zMaterialStatisticsMapper.selectOne(lqwstatis);
            if (!ObjectUtils.isEmpty(zMaterialStatistics)) {
                zMaterialStatistics.setRealitySize(BigDecimal.valueOf(zMaterialStatistics.getRealitySize()).subtract(BigDecimal.valueOf(ObjectUtils.isEmpty(item.getNumber())?0:item.getNumber())).doubleValue());
                zMaterialStatisticsMapper.updateById(zMaterialStatistics);
            }
        });
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getId, bo.getId());
        ZEngineeringInfo zEngineeringInfo = baseMapper.selectOne(lqw);
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy_MM");
        ZEngineeringInfoBo zEngineeringInfobo = new ZEngineeringInfoBo();
        zEngineeringInfobo = BeanUtil.toBean(zEngineeringInfo, ZEngineeringInfoBo.class);
        izEngiineeringPhotoService.delete(zEngineeringInfobo);
        izEngineeringMaterialService.delete(zEngineeringInfobo);

        MonthTableNameHandler.setData(simpleDateFormat.format(bo.getCreateTime()));
        baseMapper.deleteById(bo.getId());

        LambdaQueryWrapper<ZEngineeringInfo> lqw2 = Wrappers.lambdaQuery();
        lqw2.eq(StringUtils.isNotBlank(bo.getEngInfoId()), ZEngineeringInfo::getEngInfoId, bo.getEngInfoId());
        List<ZEngineeringInfo> zEngineeringInfoList = baseMapper.selectList(lqw2);
        MonthTableNameHandler.removeData();
        if (zEngineeringInfoList.size()==0)
        {
            izEngineeringReviewService.deleteByNodeId(zEngineeringInfobo);
        }
        return null;
    }
    @Override
    public List<ZEngineeringMaterialBo> getzEngineeringMaterialBoList(ZEngineeringNodeBo bo) {
        LambdaQueryWrapper<ZEngineeringInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getId()), ZEngineeringInfo::getEngInfoId, bo.getId());
        List<ZEngineeringInfo> zEngineeringInfo = baseMapper.selectList(lqw);
        List<ZEngineeringMaterialBo> zEngineeringMaterialBoList = new ArrayList<>();

        zEngineeringInfo.stream().forEach(item -> {
            ZEngineeringInfoBo zEngineeringInfoBo = BeanUtil.toBean(item, ZEngineeringInfoBo.class);
            zEngineeringMaterialBoList.addAll(izEngineeringMaterialService.query(zEngineeringInfoBo));
        });
        return zEngineeringMaterialBoList;
    }
}
