Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java
master
zy 2 months ago
parent
commit
88cc042407
  1. 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java
  2. 29
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java
  3. 186
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java

1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java

@ -25,6 +25,7 @@ public class TaskInfoRespVO {
@ExcelProperty("任务ID,主键")
private Long id;
private Integer reverseStauts;
//任务编号
@Schema(description = "任务编号", example = "你猜")

29
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java

@ -9,6 +9,9 @@ import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
/**
* 企业 Mapper
*
@ -31,10 +34,9 @@ public interface EnterpriseMapper extends BaseMapperX<EnterpriseDO> {
.eqIfPresent(EnterpriseDO::getIntroduction, reqVO.getIntroduction())
.betweenIfPresent(EnterpriseDO::getEstablishmentDate, reqVO.getEstablishmentDate())
.eqIfPresent(EnterpriseDO::getGpsLocation, reqVO.getGpsLocation())
.eqIfPresent(EnterpriseDO::getCreator, reqVO.getCreate())
.betweenIfPresent(EnterpriseDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(EnterpriseDO::getUpdater, reqVO.getUpdater())
.inIfPresent(EnterpriseDO::getId,reqVO.getIds())
// .or(w->w.eq( EnterpriseDO::getCreator, getLoginUserId()))
.orderByDesc(EnterpriseDO::getId));
}
@ -42,27 +44,4 @@ public interface EnterpriseMapper extends BaseMapperX<EnterpriseDO> {
return selectList();
}
default List<EnterpriseDO> selectList(EnterprisePageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<EnterpriseDO>()
.eqIfPresent(EnterpriseDO::getId, reqVO.getId())
.eqIfPresent(EnterpriseDO::getDepartmentId, reqVO.getDepartmentId())
.eqIfPresent(EnterpriseDO::getUserId, reqVO.getUserId())
.eqIfPresent(EnterpriseDO::getType, reqVO.getType())
.eqIfPresent(EnterpriseDO::getRegion, reqVO.getRegion())
.likeIfPresent(EnterpriseDO::getEnterprisesName, reqVO.getEnterprisesName())
.eqIfPresent(EnterpriseDO::getAddress, reqVO.getAddress())
.likeIfPresent(EnterpriseDO::getContactName, reqVO.getContactName())
.eqIfPresent(EnterpriseDO::getEnvironmentalContactPhone, reqVO.getEnvironmentalContactPhone())
.eqIfPresent(EnterpriseDO::getRegistrationNumber, reqVO.getRegistrationNumber())
.eqIfPresent(EnterpriseDO::getIntroduction, reqVO.getIntroduction())
.betweenIfPresent(EnterpriseDO::getEstablishmentDate, reqVO.getEstablishmentDate())
.eqIfPresent(EnterpriseDO::getGpsLocation, reqVO.getGpsLocation())
.eqIfPresent(EnterpriseDO::getCreator, reqVO.getCreate())
.betweenIfPresent(EnterpriseDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(EnterpriseDO::getUpdater, reqVO.getUpdater())
.inIfPresent(EnterpriseDO::getId,reqVO.getIds())
.orderByDesc(EnterpriseDO::getId));
}
}

186
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java

@ -1,14 +1,31 @@
package cn.iocoder.yudao.module.system.service.enterpriseinspections;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO;
import cn.iocoder.yudao.module.system.dal.dataobject.inspectionslog.InspectionsLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO;
import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper;
import cn.iocoder.yudao.module.system.dal.mysql.inspectionslog.InspectionsLogMapper;
import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper;
import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper;
import cn.iocoder.yudao.module.system.dal.mysql.tasktag.TaskTagMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper;
@ -25,10 +42,25 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
*/
@Service
@Validated
@Slf4j
public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsService {
@Resource
private EnterpriseInspectionsMapper enterpriseInspectionsMapper;
@Resource
private TaskInfoMapper taskInfoMapper;
@Resource
private InspectionsLogMapper inspectionsLogMapper;
@Resource
private EnterpriseMapper enterpriseMapper;
@Resource
private TaskTagMapper taskTagMapper;
@Resource
private TagLibraryMapper tagLibraryMapper;
@Resource
private AdminUserService adminUserService;
@Resource
private DeptService deptService;
@Override
public Long createEnterpriseInspections(EnterpriseInspectionsSaveReqVO createReqVO) {
@ -39,6 +71,8 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe
return enterpriseInspections.getId();
}
@Override
public void updateEnterpriseInspections(EnterpriseInspectionsSaveReqVO updateReqVO) {
// 校验存在
@ -56,17 +90,6 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe
enterpriseInspectionsMapper.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteEnterpriseInspectionsTaskId(Long taskId) {
LambdaQueryWrapper<EnterpriseInspectionsDO> taskMembersDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
taskMembersDOLambdaQueryWrapper.eq(EnterpriseInspectionsDO::getTaskId, taskId);
// 删除
return enterpriseInspectionsMapper.delete(taskMembersDOLambdaQueryWrapper);
}
private void validateEnterpriseInspectionsExists(Long id) {
if (enterpriseInspectionsMapper.selectById(id) == null) {
throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS);
@ -80,16 +103,147 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe
@Override
public PageResult<EnterpriseInspectionsDO> getEnterpriseInspectionsPage(EnterpriseInspectionsPageReqVO pageReqVO) {
return enterpriseInspectionsMapper.selectPage(pageReqVO);
final PageResult<EnterpriseInspectionsDO> enterpriseInspectionsDOPageResult = enterpriseInspectionsMapper.selectPage(pageReqVO);
if ( enterpriseInspectionsDOPageResult.getList() != null && enterpriseInspectionsDOPageResult.getList().size() > 0 ) {
enterpriseInspectionsDOPageResult.getList().forEach(item->{
//查询任务相关
final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(item.getTaskId());
if (taskInfoDO == null) {
throw exception(TASK_INFO_NOT_EXISTS);
}
item.setTaskName(taskInfoDO.getTitle());
//查询任务标签
QueryWrapper<TaskTagDO> wrapper = new QueryWrapper<>();
wrapper.eq("task_id", taskInfoDO.getId());
final List<TaskTagDO> taskTagDOS = taskTagMapper.selectList(wrapper);
List<String> tagList = new ArrayList<>();
if (taskTagDOS != null && taskTagDOS.size() > 0) {
taskTagDOS.forEach(taskTagItem->{
final TagLibraryDO tagLibraryDO = tagLibraryMapper.selectById(taskTagItem.getTagId());
if (tagLibraryDO != null) {
tagList.add(tagLibraryDO.getTagName());
}
});
}
item.setTagList(tagList);
//查询企业
final EnterpriseDO enterpriseDO = enterpriseMapper.selectById(item.getEnterpriseId());
if (enterpriseDO == null) {
throw exception(ENTERPRISE_NOT_EXISTS);
}
item.setEnterpriseName(enterpriseDO.getEnterprisesName());
//查询检查记录
QueryWrapper<InspectionsLogDO> inspectionsLogWrapper = new QueryWrapper<>();
inspectionsLogWrapper.eq("inspections_id", item.getId());
inspectionsLogWrapper.orderByDesc("create_time");
final List<InspectionsLogDO> inspectionsLogDOS = inspectionsLogMapper.selectList(inspectionsLogWrapper);
if (inspectionsLogDOS != null && inspectionsLogDOS.size() > 0) {
item.setInspectionStatus(inspectionsLogDOS.get(0).getStatus());
item.setInspectName(inspectionsLogDOS.get(0).getInspectName());
item.setCooperateWithName(inspectionsLogDOS.get(0).getCooperateWithName());
item.setExecTime(inspectionsLogDOS.get(0).getCreateTime());
//根据执法人员id 查询其所属部门
final Long userId = Long.valueOf(inspectionsLogDOS.get(0).getCreator());
final AdminUserDO user = adminUserService.getUser(userId);
if (user == null) {
throw exception(USER_NOT_EXISTS);
}
final DeptDO dept = deptService.getDept(user.getDeptId());
item.setDepartment(dept.getName());
}
});
}
return enterpriseInspectionsDOPageResult;
}
@Override
public List<EnterpriseInspectionsDO> getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO) {
return enterpriseInspectionsMapper.selectList(pageReqVO);
}
public void passOn(PassOnSaveVO passOnSaveVO) {
//查看任务状态,未签到, 整改
if (passOnSaveVO.getInspectionsId() == null || passOnSaveVO.getInspectionsId().size() == 0) {
throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS); //请选择要转交的检查记录
}
//循环记录id列表
passOnSaveVO.getInspectionsId().forEach(item->{
final EnterpriseInspectionsDO enterpriseInspectionsDO = enterpriseInspectionsMapper.selectById(item);
if (enterpriseInspectionsDO == null) {
throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS);
}
//未签到和整改状态可以转, 其他状态不能转
if (enterpriseInspectionsDO.getStatus() == 1 || enterpriseInspectionsDO.getStatus() == 2) {
InspectionsLogDO inspectionsLogNew = this.getInspectionsLogNew(item);
if (inspectionsLogNew != null && inspectionsLogNew.getStatus() == 3) {
//已经开始 就要判断是否是整改状态 整改状态才能转
enterpriseInspectionsDO.setStatus(4);
} else {
enterpriseInspectionsDO.setStatus(3);
}
enterpriseInspectionsMapper.updateById(enterpriseInspectionsDO);
AdminUserDO user = adminUserService.getUser(passOnSaveVO.getUserId());
if (user == null) {
throw exception(USER_NOT_EXISTS);
}
EnterpriseInspectionsDO inspectionsDO = new EnterpriseInspectionsDO();
inspectionsDO.setEnterpriseId(enterpriseInspectionsDO.getEnterpriseId());
inspectionsDO.setTaskId(enterpriseInspectionsDO.getTaskId());
inspectionsDO.setUserId(passOnSaveVO.getUserId());
inspectionsDO.setInspectName(user.getRealName());
enterpriseInspectionsMapper.insert(inspectionsDO);
} else {
throw exception(ENTERPRISE_INSPECTIONS_STATUS_ERROR);
}
});
}
@Override
public List<EnterpriseInspectionsDO> getListByUserIdAndTaskName(Long userId, String taskName) {
LambdaQueryWrapper<EnterpriseInspectionsDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EnterpriseInspectionsDO::getUserId, userId);
wrapper.eq(EnterpriseInspectionsDO::getTaskName, taskName);
final List<EnterpriseInspectionsDO> enterpriseInspectionsDOS = enterpriseInspectionsMapper.selectList(wrapper);
//筛选出可以转交的检查记录
List<EnterpriseInspectionsDO> list = new ArrayList<>();
if (enterpriseInspectionsDOS != null && enterpriseInspectionsDOS.size() > 0) {
enterpriseInspectionsDOS.forEach(item->{
final InspectionsLogDO inspectionsLogNew = this.getInspectionsLogNew(item.getId());
if (inspectionsLogNew == null || inspectionsLogNew.getStatus() == 3) {
//已经开始 就要判断是否是整改状态 整改状态才能转
list.add(item);
}
});
}
return list;
}
//获得检测记录最新一条
public InspectionsLogDO getInspectionsLogNew(Long inspectionsId) {
QueryWrapper<InspectionsLogDO> wrapper = new QueryWrapper<>();
wrapper.eq("inspections_id", inspectionsId);
wrapper.orderByDesc("create_time");
List<InspectionsLogDO> inspectionsLogDOS = inspectionsLogMapper.selectList(wrapper);
if (inspectionsLogDOS == null || inspectionsLogDOS.size() == 0) {
return null;
}
return inspectionsLogDOS.get(0);
}
}

Loading…
Cancel
Save