StatusFlowHeaderService.java 2.44 KB
package com.huaheng.pc.config.statusFlow.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.config.statusFlow.mapper.StatusFlowDetailMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.statusFlow.domain.StatusFlowHeader;
import com.huaheng.pc.config.statusFlow.mapper.StatusFlowHeaderMapper;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("StatusFlow")
public class StatusFlowHeaderService extends ServiceImpl<StatusFlowHeaderMapper, StatusFlowHeader> {

    @Resource
    private StatusFlowHeaderMapper statusFlowHeaderMapper;
    @Resource
    private StatusFlowDetailMapper statusFlowDetailMapper;


    public List<Map<String, Object>> flowList(String recordType){
        LambdaQueryWrapper<StatusFlowHeader> lambda = Wrappers.lambdaQuery();
        lambda.select(StatusFlowHeader::getCode, StatusFlowHeader::getName)
                .eq(StatusFlowHeader::getWarehouseCode,ShiroUtils.getWarehouseCode())
            .eq(StatusFlowHeader::getRecordType, recordType);
        return this.listMaps(lambda);
    }


    //根据模块区分出入库流程
    public List<StatusFlowHeader> shipmentStatusFlowHeaders(String moduleType){
        LambdaQueryWrapper<StatusFlowHeader> lambda = Wrappers.lambdaQuery();
        lambda.eq(StatusFlowHeader::getModuleType,moduleType)
                .eq(StatusFlowHeader::getWarehouseCode, ShiroUtils.getWarehouseCode());
        return this.list(lambda);
    }


    //复制流程
    public Boolean statusFlowCopy(String code,String newCode){
        int i = 0;
        //复制流程主表
        i = statusFlowHeaderMapper.statusFlowHeaderCopy(code,newCode);
        if(i < 1){
            throw new ServiceException("复制菜单数据失败");
        }

        //复制流程明细
        i = statusFlowDetailMapper.statusFlowDetailCopy(code,newCode);
        if(i < 1){
            throw new ServiceException("复制菜单数据失败");
        }

        //修改流程明细headerId
        i = statusFlowDetailMapper.updateHeaderId(newCode);
        if(i < 1){
            throw new ServiceException("复制菜单数据失败");
        }
        return true;
    }
}