zhangherong
2025-04-27 1007e0b552accd3288e7da6b47d8cc49a03bdf62
lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java
@@ -1,6 +1,7 @@
package org.jeecg.modules.flowable.apithird.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -14,9 +15,9 @@
import org.jeecg.modules.flowable.util.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@@ -28,7 +29,7 @@
 */
@Service
public class FlowMyBusinessServiceImpl extends ServiceImpl<FlowMyBusinessMapper, FlowMyBusiness> implements IFlowMyBusinessService {
    @Autowired
    @Resource
    private FlowMyBusinessMapper flowMyBusinessMapper;
    @Autowired
@@ -58,13 +59,10 @@
        return null;
    }
    @Transactional(isolation = Isolation.READ_COMMITTED)    // 降低隔离级别
    @Transactional   // 降低隔离级别
    public FlowMyBusiness getByDataId(String dataId) {
        LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>();
        flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId,dataId)
        ;
        //如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
        FlowMyBusiness business = this.getOne(flowMyBusinessLambdaQueryWrapper);
        FlowMyBusiness business = flowMyBusinessMapper.selectByDataId(dataId);
        return business;
    }
@@ -81,11 +79,10 @@
    /**
     * 流程-我的已办
     * @param flowMyBusinessDto
     * @param page
     * @return
     */
    public IPage<FlowTaskDto> getPageListMyBusiness(Page page, FlowMyBusinessDto flowMyBusinessDto){
        return flowMyBusinessMapper.PageListMyBusiness(page,flowMyBusinessDto);
    public List<FlowTaskDto> ListMyBusiness(FlowMyBusinessDto flowMyBusinessDto){
        return flowMyBusinessMapper.ListMyBusiness(flowMyBusinessDto);
    }
    /**
@@ -102,24 +99,45 @@
                    item.setPreNode(historicActivityInstance.getActivityName());
                }
            }
                if (item.getDoneUsers() == null){
                    item.setDoneUsers("");
                }else {
                    //去除[]
                    item.setDoneUsers(item.getDoneUsers().replaceAll("\\[", "").replaceAll("\\]", ""));
                    item.setDoneUsers(item.getDoneUsers().replaceAll("\"", ""));
                }
                //计算处理时长
                Date kssj=item.getStartTime();
                Date jssj;
                if (item.getEndTime() != null){
                    jssj=item.getEndTime();
                }else {
                    jssj=new Date();
                }
                item.setDuration(TimeUtil.howLong(kssj, jssj,2));
            if (item.getTodoUsers() == null){
                item.setTodoUsers("");
            }else {
                //去除[]
                item.setTodoUsers(item.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", ""));
                item.setTodoUsers(item.getTodoUsers().replaceAll("\"", ""));
            }
            if (item.getDoneUsers() == null){
                item.setDoneUsers("");
            }else {
                //去除[]
                item.setDoneUsers(item.getDoneUsers().replaceAll("\\[", "").replaceAll("\\]", ""));
                item.setDoneUsers(item.getDoneUsers().replaceAll("\"", ""));
            }
            //计算处理时长
            Date kssj=item.getStartTime();
            Date jssj;
            if (item.getEndTime() != null){
                jssj=item.getEndTime();
            }else {
                jssj=new Date();
            }
            item.setDuration(TimeUtil.howLong(kssj, jssj,2));
        });
        return flowMyBusinessDtoIPage;
    }
    @Override
    public FlowMyBusiness getFlowMyBusiness(String instanceId) {
        List<FlowMyBusiness> businessList = super.list(
                new QueryWrapper<FlowMyBusiness>().eq("process_instance_id", instanceId));
        return businessList.isEmpty() ? null : businessList.get(0);
    }
    @Override
    public FlowMyBusiness selectByDataId(String dataId) {
        List<FlowMyBusiness> businessList = super.list(
                new QueryWrapper<FlowMyBusiness>().eq("data_id", dataId));
        return businessList.isEmpty() ? null : businessList.get(0);
    }
}