package cn.huge.module.assist.service; import cn.huge.base.common.exception.ServiceException; import cn.huge.base.common.utils.DateUtils; import cn.huge.base.common.utils.IdUtils; import cn.huge.module.client.api.impl.CustClientImpl; import cn.huge.module.client.api.impl.UtilsClientImpl; import cn.huge.module.assist.dao.mapper.CaseAssistApplyMapper; import cn.huge.module.assist.domain.po.CaseAssistApply; import cn.huge.module.cust.dto.CtUserDTO; import cn.huge.module.mediate.constant.CaseBaseConsts; 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; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @title: 联合处置申请信息表业务逻辑处理 * @Description 联合处置申请信息表业务逻辑处理 * @company hugeinfo * @author wangwh * @Time 2024-09-05 17:25:04 * @version 1.0.0 */ @Slf4j @Service @Transactional(rollbackFor = Exception.class) public class CaseAssistApplyService extends ServiceImpl{ @Autowired private CaseAssistApplyMapper mapper; @Autowired private UtilsClientImpl utilsClient; @Autowired private CustClientImpl custClient; /** * 更新对象 * @param entity 对象 */ public void updateCaseAssistApply(CaseAssistApply entity){ try{ mapper.updateCaseAssistApply(entity); }catch (Exception e){ log.error("[CaseAssistApplyService.updateCaseAssistApply]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.updateCaseAssistApply", e); } } /** * 条件更新对象 * @param entity 对象 * @param terms 条件 */ public void updateCaseAssistApplyTerms(CaseAssistApply entity, Map terms){ try{ mapper.updateCaseAssistApplyTerms(entity, terms); }catch (Exception e){ log.error("[CaseAssistApplyService.updateCaseAssistApplyTerms]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.updateCaseAssistApplyTerms", e); } } /** * 根据编号物理删除 * @param id 查询条件集合 */ public void deleteCaseAssistApply(String id){ try{ mapper.deleteCaseAssistApply(id); }catch (Exception e){ log.error("[CaseAssistApplyService.deleteCaseAssistApply]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.deleteCaseAssistApply", e); } } /** * 按条件查询 * @param terms 条件 * @return List */ public List listTerms(Map terms){ return mapper.listTerms(terms); } /** * 按条件统计 * @param terms 条件 * @return long */ public long countTerms(Map terms){ return mapper.countTerms(terms); } /** * 按条件分页查询 * @param page 分页对象 * @param terms 条件 * @return Page */ public Page pageQuery(PageRequest page, Map terms){ long total = mapper.countTerms(terms); List content = mapper.pageTerms(page, terms); return new PageImpl(content, page, total); } /** * 新增或更新对象 * @param caseAssistApply 实体对象 */ public void saveCaseAssistApply(CaseAssistApply caseAssistApply){ try{ Date nowDate = DateUtils.getNowDate(); // 判断是否新增 if (IdUtils.checkNewId(caseAssistApply.getId())){ caseAssistApply.setId(utilsClient.getNewTimeId()); caseAssistApply.setCreateTime(nowDate); } caseAssistApply.setUpdateTime(nowDate); this.saveOrUpdate(caseAssistApply); }catch (Exception e){ log.error("[CaseAssistApplyService.saveCaseAssistApply]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.saveCaseAssistApply", e); } } /** * 添加联合处置申请 * @param caseAssistApply 实体对象 */ public void addCaseAssistApply(CaseAssistApply caseAssistApply, String userId){ try{ // 获取当前登录用户 CtUserDTO loginUser = custClient.clientGetUserAll(userId); Date now = DateUtils.getNowDate(); caseAssistApply.setApplyUnitId(loginUser.getUnitId()); caseAssistApply.setApplyUnitName(loginUser.getUnitName()); caseAssistApply.setApplyUserId(loginUser.getId()); caseAssistApply.setApplyUserName(loginUser.getTrueName()); caseAssistApply.setApplyStatus(0); caseAssistApply.setCreateTime(now); caseAssistApply.setUpdateTime(now); //todo 添加任务 mapper.insert(caseAssistApply); }catch (Exception e){ log.error("[CaseAssistApplyService.addCaseAssistApply]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.addCaseAssistApply", e); } } /** * 审核联合处置申请 * @param caseAssistApply 实体对象 */ public void reviewCaseAssistApply(CaseAssistApply caseAssistApply, String userId){ try{ // 获取当前登录用户 CtUserDTO loginUser = custClient.clientGetUserAll(userId); Date now = DateUtils.getNowDate(); caseAssistApply.setApplyStatus(1); caseAssistApply.setAuditUnitId(loginUser.getUnitId()); caseAssistApply.setAuditUnitName(loginUser.getUnitName()); caseAssistApply.setAuditUserId(loginUser.getId()); caseAssistApply.setAuditUserName(loginUser.getTrueName()); caseAssistApply.setAuditTime(now); caseAssistApply.setUpdateTime(now); //todo 修改任务状态 mapper.updateCaseAssistApply(caseAssistApply); }catch (Exception e){ log.error("[CaseAssistApplyService.reviewCaseAssistApply]调用失败,异常信息:"+e, e); throw new ServiceException("CaseAssistApplyService.reviewCaseAssistApply", e); } } /** * 根据案件编号查询联合处置申请 * @param caseId 条件 * @return long */ public List listCaseAssistApplyByCaseId(String caseId){ QueryWrapper caseAssistApplyQueryWrapper = new QueryWrapper<>(); caseAssistApplyQueryWrapper.eq("case_id", caseId).orderByDesc("create_time"); List caseAssistApplyList = mapper.selectList(caseAssistApplyQueryWrapper); return caseAssistApplyList; } }