package com.gkhy.assess.system.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.assess.common.exception.ApiException;
|
import com.gkhy.assess.system.domain.AssProject;
|
import com.gkhy.assess.system.domain.AssWorkNotification;
|
import com.gkhy.assess.system.enums.AccessoryFileTypeEnum;
|
import com.gkhy.assess.system.enums.ReportProgressEnum;
|
import com.gkhy.assess.system.mapper.AssWorkNotificationMapper;
|
import com.gkhy.assess.system.service.AssAccessoryFileService;
|
import com.gkhy.assess.system.service.AssProjectService;
|
import com.gkhy.assess.system.service.AssWorkNotificationService;
|
import com.gkhy.assess.system.utils.ShiroUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
/**
|
* <p>
|
* 从业告知表 服务实现类
|
* </p>
|
*
|
* @author kzy
|
* @since 2023-12-12 10:46:54
|
*/
|
@Service
|
public class AssWorkNotificationServiceImpl extends ServiceImpl<AssWorkNotificationMapper, AssWorkNotification> implements AssWorkNotificationService {
|
@Autowired
|
private AssProjectService projectService;
|
@Autowired
|
private AssAccessoryFileService accessoryFileService;
|
@Override
|
@Transactional(rollbackFor = RuntimeException.class)
|
public int addWorkNotification(AssWorkNotification workNotification) {
|
Long projectId=workNotification.getProjectId();
|
projectService.checkUserAllowed(projectId);
|
checkWorkNotificationCount(projectId);
|
AssProject projectById = projectService.getProjectById(projectId);
|
if (projectById==null){
|
throw new ApiException("项目不存在");
|
}
|
if(projectById.getEstimateType() != 33){
|
Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId,null, AccessoryFileTypeEnum.EMPLOYMENT_NOTICE.getCode());
|
if(fileCount==0){
|
throw new ApiException("未上传从业告知书");
|
}
|
}
|
|
//校验项目状态
|
projectService.checkReportProgress(projectId, ReportProgressEnum.ESTIMATE_PLAN);
|
workNotification.setCreateBy(ShiroUtils.getSysUser().getUsername());
|
int row=baseMapper.insert(workNotification);
|
if(row>0) {
|
//更新项目状态
|
projectService.changeReportProgress(projectId,ReportProgressEnum.WORK_NOTIFICATION);
|
}
|
return row;
|
}
|
|
public void checkWorkNotificationCount(Long projectId){
|
//校验项目下从业告知数量
|
int count= baseMapper.getCountByProjectId(projectId);
|
if(count>0){
|
throw new ApiException("项目下已存在从业告知");
|
}
|
}
|
|
@Override
|
public int editWorkNotification(AssWorkNotification workNotification) {
|
projectService.checkUserAllowed(workNotification.getProjectId());
|
workNotification.setUpdateBy(ShiroUtils.getSysUser().getUsername());
|
int row=baseMapper.updateById(workNotification);
|
return row;
|
}
|
|
@Override
|
public AssWorkNotification getWorkNotificationByProjectId(Long projectId) {
|
projectService.checkUserAllowed(projectId);
|
return baseMapper.getWorkNotificationByProjectId(projectId);
|
}
|
|
@Override
|
public AssWorkNotification getWorkNotificationById(Long workNotificationId) {
|
return baseMapper.getWorkNotificationById(workNotificationId);
|
}
|
}
|