DgArchivesDestructionServiceImpl.java 6.82 KB
package com.pashanhoo.destroy.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pashanhoo.archive.entity.DgArchivesDO;
import com.pashanhoo.archive.entity.vo.DgArchivesSearchRequest;
import com.pashanhoo.archive.service.DgArchivesService;
import com.pashanhoo.common.Result;
import com.pashanhoo.common.util.SysCode.SysCodeUtil;
import com.pashanhoo.common.util.SysCode.SysCodeVO;
import com.pashanhoo.destroy.entity.DgArchivesDestructionConverter;
import com.pashanhoo.destroy.entity.DgArchivesDestructionDO;
import com.pashanhoo.destroy.entity.vo.*;
import com.pashanhoo.destroy.mapper.DgArchivesDestructionMapper;
import com.pashanhoo.destroy.service.DgArchivesDestructionService;
import com.pashanhoo.destroycatalog.entity.DgDestructionCatalogConverter;
import com.pashanhoo.destroycatalog.service.DgDestructionCatalogService;
import com.pashanhoo.lend.mapper.DgLendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 档案销毁 服务实现类
 * </p>
 *
 * @author
 * @since 2021-11-05
 */
@Service
public class DgArchivesDestructionServiceImpl extends ServiceImpl<DgArchivesDestructionMapper, DgArchivesDestructionDO> implements DgArchivesDestructionService {

    @Autowired
    private DgArchivesDestructionConverter dgarchivesdestructionConverter;

    @Autowired
    private DgArchivesDestructionMapper dgarchivesdestructionMapper;

    @Autowired
    private DgDestructionCatalogService catalogService;
    @Autowired
    private DgDestructionCatalogConverter catalogConverter;
    @Autowired
    private DgArchivesService archivesService;
    @Autowired
    SysCodeUtil sysCodeUtil;
    @Autowired
    private DgLendMapper dglendMapper;


    /**
     * 新增记录
     * @param request
     * @return
     */
    @Override
    public Result insertDgArchivesDestruction(AddDgArchivesDestructionRequest request) {
        DgArchivesDestructionDO dgarchivesdestructionDO = dgarchivesdestructionConverter.addRequest2DO(request);
        String id= IdWorker.get32UUID();
        dgarchivesdestructionDO.setBsmDestruction(id);
        this.save(dgarchivesdestructionDO);
        return Result.ok(id);
    }

    @Override
    public Result showArchivesForDestruction(DgArchivesSearchRequest request) {
        request.setDazt(4);
        return Result.ok(archivesService.searchDgArchivesList(request));
    }

    /**
     * 根据主键查询记录详情
     * @param id
     * @return
     */
    @Override
    public DgArchivesDestructionDetailVO getDgArchivesDestructionDetailById(String id) {
        DgArchivesDestructionDO dgarchivesdestructionDO = this.getById(id);
        return dgarchivesdestructionConverter.do2DetailVO(dgarchivesdestructionDO);
    }

    /**
     * 修改单条记录
     * @param request
     * @return
     */
    @Override
    public boolean updateDgArchivesDestruction(UpdateDgArchivesDestructionRequest request) {
        DgArchivesDestructionDO dgarchivesdestructionDO = dgarchivesdestructionConverter.updateRequest2DO(request);
        return this.updateById(dgarchivesdestructionDO);
    }

    /**
     * 根据条件进行列表查询
     * @param request
     * @return
     */
    @Override
    public Result searchDgArchivesDestructionList(DgArchivesDestructionSearchRequest request) {
        PageHelper.startPage(request.getCurrentPage(), request.getPageSize());
        List<DgArchivesDestructionListVO> jyListVOList = dgarchivesdestructionMapper.selectXhResult(request);
        PageInfo<DgArchivesDestructionListVO> pageInfo = new PageInfo<DgArchivesDestructionListVO>(jyListVOList);
        return Result.ok(pageInfo);

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result deleteDgArchivesDestruction(String bsm_destruction) {
        //删除销毁记录表数据
        dgarchivesdestructionMapper.deleteById(bsm_destruction);
        //删除档案销毁目录数据
        catalogService.deleteDestructionCatalog(bsm_destruction);
        //修改档案信息表状态
        dgarchivesdestructionMapper.updateArchivesStatus(bsm_destruction,"4");
        return Result.ok();
    }

    @Override
    public Result queryArchivesInfo(String bsm_destruction) {
        return Result.ok(dgarchivesdestructionMapper.queryArchivesInfo(bsm_destruction));
    }

    @Override
    public Result deleteDestructionArchivescataLog(String bsmArchives) {
        catalogService.deleteDestructionCatalog(bsmArchives);
        return Result.ok();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result addDestructionArchivesInfo(List<String> idList) {
        //获取补录编号
        SysCodeVO sysCodeVO = new SysCodeVO();
        sysCodeVO.setTaskno("XH" + DateUtil.year(DateUtil.date()));
        sysCodeVO.setCtype("sequence");
        sysCodeVO.setTaskname("补录序列号");
        sysCodeVO.setTaskchild(5);
        String xhbh = sysCodeUtil.getSequence(sysCodeVO);
        //1.新增销毁案卷信息表数据
        String archivesUuid=IdWorker.get32UUID();
        DgArchivesDestructionDO destructionDO=new DgArchivesDestructionDO();
        destructionDO.setBsmDestruction(archivesUuid);
        destructionDO.setXhqcbh(xhbh);
        destructionDO.setFqr("admin");
        destructionDO.setShyj("同意");
        destructionDO.setState("1");
        dgarchivesdestructionMapper.insert(destructionDO);
        //2.新增销毁目录信息表
        catalogService.saveBatchDestructionCatalog(idList,archivesUuid);
        //3.档案信息修改状态为修改中
        dglendMapper.updateArchivesStatusBatch(idList,"5");
        return Result.ok();
    }

    @Override
    public Result updateArchivesStateByDestruction(String bsm_destruction) {
        //1.修改档案信息表状态
        dgarchivesdestructionMapper.updateArchivesStatus(bsm_destruction,"6");
        //2.修改档案销毁信息表中的状态
        dgarchivesdestructionMapper.updateDestructionArchivesStatus(bsm_destruction,"2");
        return Result.ok();
    }

    @Override
    public Result updateStateByArchives(List<String> idList) {
        //1.修改档案基本信息表中的状态
        dgarchivesdestructionMapper.updateArchivesStatusBatch(idList,"6");
        return Result.ok();
    }



    /**
     * 根据销毁清册编号获取左侧档案号菜单
     *
     * @param xhqcbh 销毁清册编号
     * @return
     */
    @Override
    public List getDestroyLeftMenu(String xhqcbh) {

        List<DgArchivesDO> dgArchivesDestructionDOS = dgarchivesdestructionMapper.getDestroyLeftMenu(xhqcbh);
        return dgArchivesDestructionDOS;
    }
}