package cn.huge.module.mode.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.cust.dto.CtUserDTO;
|
import cn.huge.module.mode.dao.mapper.ModeSuperviseMapper;
|
import cn.huge.module.mode.domain.po.ModeSupervise;
|
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.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @title: 督办模板表业务逻辑处理
|
* @Description 督办模板表业务逻辑处理
|
* @company hugeinfo
|
* @author wangwh
|
* @Time 2024-09-07 10:31:33
|
* @version 1.0.0
|
*/
|
@Slf4j
|
@Service
|
@Transactional(rollbackFor = Exception.class)
|
public class ModeSuperviseService extends ServiceImpl<ModeSuperviseMapper, ModeSupervise>{
|
|
@Autowired
|
private ModeSuperviseMapper mapper;
|
|
@Autowired
|
private UtilsClientImpl utilsClient;
|
|
@Autowired
|
private CustClientImpl custClient;
|
|
/**
|
* 更新对象
|
* @param entity 对象
|
*/
|
public void updateModeSupervise(ModeSupervise entity){
|
try{
|
mapper.updateModeSupervise(entity);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.updateModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.updateModeSupervise", e);
|
}
|
}
|
|
/**
|
* 条件更新对象
|
* @param entity 对象
|
* @param terms 条件
|
*/
|
public void updateModeSuperviseTerms(ModeSupervise entity, Map<String, Object> terms){
|
try{
|
mapper.updateModeSuperviseTerms(entity, terms);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.updateModeSuperviseTerms]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.updateModeSuperviseTerms", e);
|
}
|
}
|
|
/**
|
* 根据编号物理删除
|
* @param id 查询条件集合
|
*/
|
public void deleteModeSupervise(String id){
|
try{
|
mapper.deleteModeSupervise(id);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.deleteModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.deleteModeSupervise", e);
|
}
|
}
|
|
/**
|
* 按条件查询
|
* @param terms 条件
|
* @return List
|
*/
|
public List<ModeSupervise> listTerms(Map<String, Object> terms){
|
return mapper.listTerms(terms);
|
}
|
|
/**
|
* 按条件统计
|
* @param terms 条件
|
* @return long
|
*/
|
public long countTerms(Map<String, Object> terms){
|
return mapper.countTerms(terms);
|
}
|
|
/**
|
* 按条件分页查询
|
* @param page 分页对象
|
* @param terms 条件
|
* @return Page
|
*/
|
public Page<ModeSupervise> pageQuery(PageRequest page, Map<String, Object> terms){
|
long total = mapper.countTerms(terms);
|
List<ModeSupervise> content = mapper.pageTerms(page, terms);
|
return new PageImpl<ModeSupervise>(content, page, total);
|
}
|
|
/**
|
* 新增或更新对象
|
* @param modeSupervise 实体对象
|
*/
|
public void saveModeSupervise(ModeSupervise modeSupervise){
|
try{
|
Date nowDate = DateUtils.getNowDate();
|
// 判断是否新增
|
if (IdUtils.checkNewId(modeSupervise.getId())){
|
modeSupervise.setId(utilsClient.getNewTimeId());
|
modeSupervise.setCreateTime(nowDate);
|
}
|
modeSupervise.setUpdateTime(nowDate);
|
this.saveOrUpdate(modeSupervise);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.saveModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.saveModeSupervise", e);
|
}
|
}
|
|
/**
|
* 按条件分页查询
|
* @param page 分页对象
|
* @param terms 条件
|
* @return Page
|
*/
|
public Page<ModeSupervise> pageModeSupervise(PageRequest page, Map<String, Object> terms){
|
long total = mapper.countModeSupervise(terms);
|
List<ModeSupervise> content = mapper.pageModeSupervise(page, terms);
|
return new PageImpl<ModeSupervise>(content, page, total);
|
}
|
|
/**
|
* 修改状态
|
* @param id 模板编号
|
* @param modeStatus 状态
|
*/
|
public void updateModeStatus(String id, Integer modeStatus, String userId){
|
try{
|
Date nowDate = DateUtils.getNowDate();
|
CtUserDTO loginUser = custClient.clientGetUserAll(userId);
|
ModeSupervise modeSupervise = new ModeSupervise();
|
modeSupervise.setId(id);
|
modeSupervise.setModeStatus(modeStatus);
|
modeSupervise.setOperUserId(loginUser.getId());
|
modeSupervise.setOperUserName(loginUser.getTrueName());
|
modeSupervise.setUpdateTime(nowDate);
|
Map<String, Object> terms = new HashMap<>();
|
terms.put("modeType", 2);
|
mapper.updateModeSuperviseTerms(modeSupervise, terms);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.saveModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.saveModeSupervise", e);
|
}
|
}
|
|
/**
|
* 修改状态
|
* @param modeSupervise 模板信息
|
* @param userId 用户编号
|
*/
|
public void addModeSupervise(ModeSupervise modeSupervise, String userId){
|
try{
|
Date nowDate = DateUtils.getNowDate();
|
CtUserDTO loginUser = custClient.clientGetUserAll(userId);
|
modeSupervise.setId(IdUtils.getNewTimeId());
|
//默认添加所属人和组织为当前用户
|
modeSupervise.setModeUserId(loginUser.getId());
|
modeSupervise.setModeUserName(loginUser.getTrueName());
|
modeSupervise.setModeUnitId(loginUser.getUnitId());
|
modeSupervise.setModeUnitName(loginUser.getUnitName());
|
modeSupervise.setModeStatus(0);
|
modeSupervise.setUseNum(0);
|
modeSupervise.setOperUserId(loginUser.getId());
|
modeSupervise.setOperUserName(loginUser.getTrueName());
|
modeSupervise.setDeleteStatus(0);
|
modeSupervise.setUpdateTime(nowDate);
|
modeSupervise.setCreateTime(nowDate);
|
//todo 模板展示顺序
|
mapper.insert(modeSupervise);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.addModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.addModeSupervise", e);
|
}
|
}
|
|
/**
|
* 使用次数增加
|
* @param id 模板编号
|
*/
|
public void addUseNum(String id){
|
try{
|
mapper.addUseNum(id);
|
}catch (Exception e){
|
log.error("[ModeSuperviseService.saveModeSupervise]调用失败,异常信息:"+e, e);
|
throw new ServiceException("ModeSuperviseService.saveModeSupervise", e);
|
}
|
}
|
}
|