管道基础大数据平台系统开发-【后端】-Server
13693261870
2022-12-24 10c2e86f67ef4a992e5cdd4f8d28a5893b066e4d
src/main/java/com/lf/server/service/show/ApplyService.java
@@ -1,10 +1,17 @@
package com.lf.server.service.show;
import com.lf.server.entity.ctrl.DownloadReqEntity;
import com.lf.server.entity.show.ApplyEntity;
import com.lf.server.entity.show.FlowEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.Md5Helper;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.show.ApplyMapper;
import org.hsqldb.rights.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@@ -15,6 +22,9 @@
public class ApplyService implements ApplyMapper {
    @Autowired
    ApplyMapper applyMapper;
    @Autowired
    FlowService flowService;
    @Override
    public Integer selectCount(Integer userid) {
@@ -66,9 +76,71 @@
        return applyMapper.updates(list);
    }
    public Integer insertApply(){
    /**
     * 插入数据申请
     */
    public Integer insertApply(UserEntity ue, DownloadReqEntity dr) {
        ApplyEntity apply = getApplyEntity(ue, dr);
        int rows = applyMapper.insert(apply);
        if (0 == rows) {
            return 0;
        }
        List<FlowEntity> list = getFlowEntities(apply.getId(), ue, dr);
        rows = flowService.inserts(list);
        return 0;
        return rows;
    }
    /**
     * 获取数据申请实体类
     */
    private ApplyEntity getApplyEntity(UserEntity ue, DownloadReqEntity dr) {
        String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd()));
        ApplyEntity apply = new ApplyEntity();
        apply.setUserid(ue.getId());
        apply.setDepids(StringHelper.join(dr.getIds(), ","));
        apply.setTabs(StringHelper.join(dr.getTabs(), ","));
        apply.setEntities(StringHelper.join(dr.getEntities(), ","));
        apply.setWkt(dr.getWkt());
        apply.setPwd(dbPwd);
        apply.setStatus(0);
        apply.setCount(dr.getIds().size());
        apply.setDescr(dr.getDescr());
        apply.setCreateUser(ue.getId());
        return apply;
    }
    /**
     * 获取申请流程实体类集合
     */
    private List<FlowEntity> getFlowEntities(Integer applyId, UserEntity ue, DownloadReqEntity dr) {
        List<FlowEntity> list = new ArrayList<>();
        for (Integer depid : dr.getIds()) {
            UserEntity user = selectUserByDepid(depid);
            FlowEntity flow = new FlowEntity();
            flow.setApplyid(applyId);
            flow.setDepid(depid);
            flow.setUserid(user.getId());
            flow.setStatus(0);
            flow.setDescr(null);
            flow.setCreateUser(ue.getId());
            list.add(flow);
        }
        return list;
    }
    /**
     * 根据单位ID查询用户
     */
    private UserEntity selectUserByDepid(Integer depid) {
        //
        return null;
    }
}