管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-11 4c882f00d9ee90d43a1c330683a612063ce64f04
src/main/java/com/lf/server/service/show/ApplyService.java
@@ -1,5 +1,6 @@
package com.lf.server.service.show;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.DownloadReqEntity;
import com.lf.server.entity.show.ApplyEntity;
import com.lf.server.entity.show.FlowEntity;
@@ -7,6 +8,8 @@
import com.lf.server.helper.AesHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.mapper.show.ApplyMapper;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.sys.UserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,7 +33,13 @@
    FlowService flowService;
    @Autowired
    UserService userService;
    @Autowired
    DataLibService dataLibService;
    @Autowired
    DownloadService downloadService;
    private final static Log log = LogFactory.getLog(ApplyService.class);
@@ -134,9 +143,12 @@
        }
        List<FlowEntity> list = getFlowEntities(apply.getId(), ue, dr);
        rows = flowService.inserts(list);
        if (list.isEmpty()) {
            applyMapper.delete(apply.getId());
            throw new Exception("找不到待审核人");
        }
        return rows;
        return flowService.inserts(list);
    }
    /**
@@ -145,6 +157,7 @@
    private ApplyEntity getApplyEntity(UserEntity ue, DownloadReqEntity dr) throws Exception {
        // String dbPwd = Md5Helper.reverse(Md5Helper.generate(dr.getPwd()))
        String aesPwd = AesHelper.encrypt(dr.getPwd());
        String gids = null == dr.getIds() || dr.getIds().isEmpty() ? null : StringHelper.join(dr.getIds(), ",");
        ApplyEntity apply = new ApplyEntity();
        apply.setUserid(ue.getId());
@@ -157,6 +170,10 @@
        apply.setCount(dr.getDepcodes().size());
        apply.setDescr(dr.getDescr());
        apply.setCreateUser(ue.getId());
        apply.setDepcode(dr.getDepcode());
        apply.setDircodes(dr.getDirs());
        apply.setGids(gids);
        apply.setFilters(dr.getFilter());
        return apply;
    }
@@ -169,12 +186,12 @@
        for (String depcode : dr.getDepcodes()) {
            UserEntity user = selectUserByDepcode(depcode);
            if (null == user) {
                continue;
                user = userService.selectByUid(StaticData.ADMIN);
            }
            FlowEntity flow = new FlowEntity();
            flow.setApplyid(applyId);
            flow.setDepcode(user.getDepcode());
            flow.setDepcode(depcode);
            flow.setUserid(user.getId());
            flow.setStatus(0);
            flow.setDescr(null);
@@ -191,12 +208,41 @@
     */
    public void zipDbData(UserEntity ue, ApplyEntity entity) {
        try {
            List<String> entities = Arrays.asList(entity.getEntities().split(","));
            List<String> entities = Arrays.asList(entity.getEntities().split(StaticData.COMMA));
            String pwd = AesHelper.decrypt(entity.getPwd());
            dataLibService.createZipFile(ue, entities, null, null, entity.getWkt(), pwd);
            DownloadReqEntity dr = new DownloadReqEntity();
            dr.setEntities(entities);
            dr.setWkt(dr.getWkt());
            dr.setPwd(pwd);
            dr.setDepcode(entity.getDepcode());
            dr.setDirs(entity.getDircodes());
            dr.setIds(getIds(entity));
            dr.setFilter(entity.getFilters());
            String guid = "sysmeta".equals(entity.getEntities()) ? "" : dataLibService.downloadDbReq(ue, dr);
            if (!StringHelper.isEmpty(guid)) {
                entity.setGuid(guid);
                update(entity);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    /**
     * 获取ID集合
     */
    private List<Integer> getIds(ApplyEntity entity) {
        if (StringHelper.isEmpty(entity.getGids())) {
            return null;
        }
        List<Integer> list = new ArrayList<>();
        for (String str : entity.getGids().split(StaticData.COMMA)) {
            list.add(Integer.parseInt(str));
        }
        return list;
    }
}