forked from gzzfw/backEnd/gz-dyh

zhouxiantao
2024-09-27 b0a34952a61975657bd3a2386fe38047c4e03723
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseUrgingService.java
@@ -3,11 +3,13 @@
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.client.api.impl.CustClientImpl;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.cases.dao.mapper.CaseUrgingMapper;
import cn.huge.module.cases.domain.po.CaseUrging;
import cn.huge.module.cust.dto.PaUserDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -139,8 +141,22 @@
     * 新增或更新对象
     * @param caseUrging 实体对象
     */
    public void saveCaseUrgingWechat(String userId,CaseUrging caseUrging){
    public String saveCaseUrgingWechat(String userId,CaseUrging caseUrging){
        try{
            //查询是否已经有催办
            QueryWrapper<CaseUrging> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("case_id", caseUrging.getCaseId());
            queryWrapper.orderByDesc("create_time");
            queryWrapper.last("limit 1");
            CaseUrging caseUrgingOld = mapper.selectOne(queryWrapper);
            if(ObjectUtils.isNotEmpty(caseUrgingOld)){
                //计算创建时间和当前时间是否超过24小时
                Integer differHour = DateUtils.getDifferHour(new Date(), caseUrgingOld.getCreateTime());
                if(differHour < 24){
                    return "催办间隔时间不能小于24小时";
                }
            }
            // 获取当前登录用户
            PaUserDTO loginUser = custClient.paclientGetUser(userId);
            Date nowDate = DateUtils.getNowDate();
@@ -159,6 +175,28 @@
            log.error("[CaseUrgingService.saveCaseUrging]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseUrgingService.saveCaseUrging", e);
        }
        return null;
    }
    public Integer countByCaseId(String caseId){
        Integer count = 0;
        QueryWrapper<CaseUrging> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("case_id", caseId);
        queryWrapper.isNotNull("reply_user_id");
        Integer number = mapper.selectCount(queryWrapper);
        if(ObjectUtils.isNotEmpty(number)){
            count = number;
        }
        return count;
    }
    public List<CaseUrging> listByCaseId(String caseId){
        QueryWrapper<CaseUrging> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("case_id", caseId);
        queryWrapper.isNotNull("reply_user_id");
        queryWrapper.orderByDesc("reply_time");
        List<CaseUrging> caseUrgings = mapper.selectList(queryWrapper);
        return caseUrgings;
    }
}