Browse Source

Merge remote-tracking branch 'origin/master'

master
zy 2 months ago
parent
commit
889410bd12
  1. 8
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoPageReqVO.java
  2. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/HomeController.java
  3. 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java
  4. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java
  5. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java
  6. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/datapermission/config/DataPermissionConfiguration.java
  7. 27
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java
  8. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java
  9. 70
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java
  10. 126
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java
  11. 51
      yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

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

@ -64,6 +64,10 @@ public class TaskInfoPageReqVO extends PageParam {
@Schema(description = "总共几步")
private Integer taskTotal;
private LocalDateTime startTime;
private LocalDateTime endTime;
@Schema(description = "企业集合", example = "1")
private List<Long> enterpriseInspectionsIdes;
@ -79,10 +83,10 @@ public class TaskInfoPageReqVO extends PageParam {
private Integer selectWeek;
@Schema(description = "用户id", example = "1")
private Integer userId;
private Long userId;
@Schema(description = "部门id", example = "1")
private Integer deptId;
private Long deptId;
@Schema(description = "企业id", example = "1")
private Long enterpriseId;

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/HomeController.java

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.home;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO;
import cn.iocoder.yudao.module.system.service.home.HomeService;
import io.swagger.v3.oas.annotations.Operation;
@ -30,7 +31,7 @@ public class HomeController {
@GetMapping("/appCount1")
@Operation(summary = "app首页统计第一块")
// @PreAuthorize("@ss.hasPermission('system:inspections-log:create')")
public CommonResult<List<InspectionsLogAppListVO>> signInList(HomeSelectVO homeSelectVO) {
public CommonResult<HomeCountResVO> signInList(HomeSelectVO homeSelectVO) {
return success(homeService.appCount1(homeSelectVO));
}

13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.system.controller.home.vo;
import lombok.Data;
@Data
public class HomeCountResVO {
//任务总数
private Long taskCount;
//执法总数
private Long inspectionsCount;
private Long enterpriseCount;
}

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

@ -28,7 +28,7 @@ public interface EnterpriseMapper extends BaseMapperX<EnterpriseDO> {
.eqIfPresent(EnterpriseDO::getRegion, reqVO.getRegion())
.likeIfPresent(EnterpriseDO::getEnterprisesName, reqVO.getEnterprisesName())
.eqIfPresent(EnterpriseDO::getAddress, reqVO.getAddress())
.eqIfPresent(EnterpriseDO::getIsAudit, 1)
.eqIfPresent(EnterpriseDO::getIsAudit, reqVO.getIsAudit())
.eqIfPresent(EnterpriseDO::getEnterprisesStatus, reqVO.getEnterprisesStatus())
.likeIfPresent(EnterpriseDO::getContactName, reqVO.getContactName())
.eqIfPresent(EnterpriseDO::getEnvironmentalContactPhone, reqVO.getEnvironmentalContactPhone())

2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java

@ -61,7 +61,7 @@ public interface TaskInfoMapper extends BaseMapperX<TaskInfoDO> {
}
//优化任务查询
PageResult<TaskInfoDO> selectMyPage(TaskInfoPageReqVO reqVO);
IPage<TaskInfoDO> selectMyPage(Page<TaskInfoDO> page, @Param("params") TaskInfoPageReqVO reqVO);
//根据企业id查任务
IPage<TaskInfoDO> selectPageByEnterpriseId(Page<TaskInfoDO> page, @Param("reqVO") TaskInfoPageReqVO reqVO);

6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/datapermission/config/DataPermissionConfiguration.java

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.system.framework.datapermission.config;
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.user.AdminUserDO;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import org.springframework.context.annotation.Bean;
@ -22,6 +23,11 @@ public class DataPermissionConfiguration {
rule.addDeptColumn(DeptDO.class, "id");
// user
rule.addUserColumn(AdminUserDO.class, "id");
//enterprise
rule.addDeptColumn(EnterpriseDO.class, "department_id");
rule.addUserColumn(EnterpriseDO.class, "user_id");
};
}

27
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java

@ -189,25 +189,24 @@ public class EnterpriseServiceImpl implements EnterpriseService {
return enterpriseMapper.selectList(pageReqVO);
}
@Override
public PageResult<EnterpriseDO> getEnterpriseByUserId(EnterprisePageReqVO pageReqVO) {
//根据不同身份查询企业
//专管员查询 user_id
//队长 查询部门 所有的 user_id in
QueryWrapper<UserRoleDO> roleDOQueryWrapper = new QueryWrapper<>();
roleDOQueryWrapper.eq("user_id", getLoginUserId());
final List<UserRoleDO> userRoleDOS = userRoleMapper.selectList(roleDOQueryWrapper);
final List<Long> collect = userRoleDOS.stream().map(item -> item.getRoleId()).collect(Collectors.toList());
//判断 collect 里面是否包含 roleId = 11
if (collect.contains(11L)) {
// //队长
// pageReqVO.setUserId(null);
// pageReqVO.setDeptId(null);
} else if (collect.contains(155L)) {
//专管员
pageReqVO.setUserId(getLoginUserId());
}
// QueryWrapper<UserRoleDO> roleDOQueryWrapper = new QueryWrapper<>();
// roleDOQueryWrapper.eq("user_id", getLoginUserId());
// final List<UserRoleDO> userRoleDOS = userRoleMapper.selectList(roleDOQueryWrapper);
// final List<Long> collect = userRoleDOS.stream().map(item -> item.getRoleId()).collect(Collectors.toList());
// //判断 collect 里面是否包含 roleId = 11
// if (collect.contains(11L)) {
//// //队长
//// pageReqVO.setUserId(null);
//// pageReqVO.setDeptId(null);
// } else if (collect.contains(155L)) {
// //专管员
// pageReqVO.setUserId(getLoginUserId());
// }
// pageReqVO.setCreate(getLoginUserId().toString());
final PageResult<EnterpriseDO> enterpriseDOPageResult = enterpriseMapper.selectPage(pageReqVO);

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java

@ -1,10 +1,11 @@
package cn.iocoder.yudao.module.system.service.home;
import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO;
import java.util.List;
public interface HomeService {
List<InspectionsLogAppListVO> appCount1(HomeSelectVO homeSelectVO);
HomeCountResVO appCount1(HomeSelectVO homeSelectVO);
}

70
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java

@ -1,15 +1,83 @@
package cn.iocoder.yudao.module.system.service.home;
import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.EnterprisePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO;
import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO;
import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO;
import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper;
import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper;
import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService;
import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class HomeServiceImpl implements HomeService{
@Resource
private EnterpriseMapper enterpriseMapper;
@Resource
private TaskInfoService taskInfoService;
@Resource
private TaskInfoMapper taskInfoMapper;
@Resource
private EnterpriseTagMapper enterpriseTagMapper;
@Resource
private AdminUserService adminUserService;
@Resource
private DeptService deptService;
@Override
public List<InspectionsLogAppListVO> appCount1(HomeSelectVO homeSelectVO) {
public HomeCountResVO appCount1(HomeSelectVO homeSelectVO) {
HomeCountResVO homeCountResVO = new HomeCountResVO();
LambdaQueryWrapper<EnterpriseDO> enterpriseDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
//按时间查询
if (homeSelectVO.getSelectWeek() != null) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime[] dateList = new LocalDateTime[2];
switch (homeSelectVO.getSelectWeek()) {
case 1:
dateList[0] = now.minusDays(3); // 三天前
break;
case 2:
dateList[0] = now.minusWeeks(1); // 一周前
break;
case 3:
dateList[0] = now.minusMonths(1); // 一月前
break;
case 4:
dateList[0] = now.minusYears(1); // 一年前
break;
}
dateList[1] = now;
enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, dateList[0], dateList[1]);
}
final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper);
homeCountResVO.setEnterpriseCount(enterpriseCount);
// taskInfoService.getTaskInfoAppPage()
//根据不同的身份查询
return null;
// return List.of();
}

126
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java

@ -240,91 +240,84 @@ public class TaskInfoServiceImpl implements TaskInfoService {
@Override
public PageResult<TaskInfoDO> getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO) {
//按标签查询
if (pageReqVO.getTagList() != null && pageReqVO.getTagList().size() > 0) {
LambdaQueryWrapper<TaskTagDO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(TaskTagDO::getTagId, pageReqVO.getTagList());
final List<TaskTagDO> taskTagDOS = taskTagMapper.selectList(wrapper);
if (taskTagDOS != null && taskTagDOS.size() > 0) {
pageReqVO.setTagList(taskTagDOS.stream().map(item->item.getTaskId()).collect(Collectors.toList()));
}
}
// //按标签查询
// if (pageReqVO.getTagList() != null && pageReqVO.getTagList().size() > 0) {
// LambdaQueryWrapper<TaskTagDO> wrapper = new LambdaQueryWrapper<>();
// wrapper.in(TaskTagDO::getTagId, pageReqVO.getTagList());
// final List<TaskTagDO> taskTagDOS = taskTagMapper.selectList(wrapper);
// if (taskTagDOS != null && taskTagDOS.size() > 0) {
// pageReqVO.setTagList(taskTagDOS.stream().map(item->item.getTaskId()).collect(Collectors.toList()));
// }
// }
//按时间查询
if (pageReqVO.getSelectWeek() != null) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime[] dateList = new LocalDateTime[2];
pageReqVO.setEndTime(now);
LocalDateTime startTime = null;
switch (pageReqVO.getSelectWeek()) {
case 1:
dateList[0] = now.minusDays(3); // 三天前
startTime = now.minusDays(3); // 三天前
break;
case 2:
dateList[0] = now.minusWeeks(1); // 一周前
startTime = now.minusWeeks(1); // 一周前
break;
case 3:
dateList[0] = now.minusMonths(1); // 一月前
startTime = now.minusMonths(1); // 一月前
break;
case 4:
dateList[0] = now.minusYears(1); // 一年前
startTime = now.minusYears(1); // 一年前
break;
}
dateList[1] = now;
pageReqVO.setEndDate(dateList);
pageReqVO.setStartTime(startTime);
}
//根据不同的角色查询
/*
管理员局长查全部
检查员查自己的
队长 查本部门
*/
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
final AdminUserDO user1 = adminUserService.getUser(loginUserId);
if (user1.getPostIds().contains(1l) || user1.getPostIds().contains(2l)) {
//全部
} else if (user1.getPostIds().contains(4l)) {
//本部门
pageReqVO.setDeptId(user1.getDeptId());
} else if (user1.getPostIds().contains(5l)) {
//自己
pageReqVO.setUserId(loginUserId);
}
final PageResult<TaskInfoDO> taskInfoDOPageResult = taskInfoMapper.selectAppPage(pageReqVO);
if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) {
taskInfoDOPageResult.getList().forEach(item->{
QueryWrapper<EnterpriseInspectionsDO> wrapper = new QueryWrapper<>();
wrapper.eq("task_id", item.getId());
//根据不同的角色查询
/*
管理员局长查全部
检查员查自己的
队长 查本部门
*/
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
final AdminUserDO user1 = adminUserService.getUser(loginUserId);
if (user1.getPostIds().contains(1l) || user1.getPostIds().contains(2l)) {
//全部
} else if (user1.getPostIds().contains(4l)) {
//本部门
final List<AdminUserDO> adminUserDOS = adminUserMapper.selectList(new QueryWrapper<AdminUserDO>().eq("dept_id", user1.getDeptId()));
if (adminUserDOS != null || adminUserDOS.size() > 0) {
final List<Long> collect = adminUserDOS.stream().map(res -> res.getId()).collect(Collectors.toList());
wrapper.in("user_id", collect);
}
} else if (user1.getPostIds().contains(5l)) {
//自己
wrapper.eq("user_id", loginUserId);
}
// final PageResult<TaskInfoDO> taskInfoDOPageResult = taskInfoMapper.selectAppPage(pageReqVO);
item.setTaskExecNum(0);
Page<TaskInfoDO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
final IPage<TaskInfoDO> taskInfoDOIPage = taskInfoMapper.selectMyPage(page, pageReqVO);
final PageResult<TaskInfoDO> taskInfoDOPageResult = new PageResult<>(taskInfoDOIPage.getRecords(), taskInfoDOIPage.getTotal());
List<EnterpriseInspectionsDO> enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper);
log.info("enterpriseInspectionsDOList:{}", enterpriseInspectionsDOList);
if (enterpriseInspectionsDOList != null && enterpriseInspectionsDOList.size() > 0) {
item.setTaskExecNum(enterpriseInspectionsDOList.size());
final List<EnterpriseInspectionsDO> collect = enterpriseInspectionsDOList.stream().filter(res -> res.getStatus() == 5).collect(Collectors.toList());
item.setTaskFinishNum(collect.size());
}
if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) {
taskInfoDOPageResult.getList().forEach(item->{
// item.setTaskExecNum(0);
//
// List<EnterpriseInspectionsDO> enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper);
// log.info("enterpriseInspectionsDOList:{}", enterpriseInspectionsDOList);
// if (enterpriseInspectionsDOList != null && enterpriseInspectionsDOList.size() > 0) {
// item.setTaskExecNum(enterpriseInspectionsDOList.size());
// final List<EnterpriseInspectionsDO> collect = enterpriseInspectionsDOList.stream().filter(res -> res.getStatus() == 5).collect(Collectors.toList());
// item.setTaskFinishNum(collect.size());
// }
//获取任务标签
QueryWrapper<TaskTagDO> wrapper1 = new QueryWrapper<>();
wrapper1.eq("task_id", item.getId());
List<TaskTagDO> taskTagDOList = taskTagMapper.selectList(wrapper1);
if (taskTagDOList != null && taskTagDOList.size() > 0) {
final List<Long> collect = taskTagDOList.stream().map(TaskTagDO::getTagId).collect(Collectors.toList());
final List<TagLibraryDO> tagLibraryDOS = tagLibraryMapper.selectByIds(collect);
if (tagLibraryDOS != null && tagLibraryDOS.size() > 0) {
item.setTagList(tagLibraryDOS.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList()));
}
final List<TagLibraryDO> tagLibraryDOS1 = tagLibraryService.listByTaskId(item.getId());
if (tagLibraryDOS1 != null && tagLibraryDOS1.size() > 0) {
item.setTagList(tagLibraryDOS1.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList()));
}
enterpriseInspectionsMapper.selectList();
});
}
@ -350,9 +343,10 @@ public class TaskInfoServiceImpl implements TaskInfoService {
LambdaQueryWrapper<EnterpriseInspectionsDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EnterpriseInspectionsDO::getTaskId, item.getId());
wrapper.eq(EnterpriseInspectionsDO::getEnterpriseId, pageReqVO.getEnterpriseId());
final EnterpriseInspectionsDO enterpriseInspectionsDO = enterpriseInspectionsMapper.selectOne(wrapper);
item.setInspectionsId(enterpriseInspectionsDO.getId());
final List<EnterpriseInspectionsDO> enterpriseInspectionsDO = enterpriseInspectionsMapper.selectList(wrapper);
if (enterpriseInspectionsDO != null && enterpriseInspectionsDO.size() > 0) {
item.setInspectionsId(enterpriseInspectionsDO.get(0).getId());
}
//发布部门,
final Long userId = Long.valueOf(item.getCreator());

51
yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

@ -12,33 +12,48 @@
<select id="selectMyPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO">
SELECT
t.*,
count(ei.task_id),
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS status_2_count
count(ei.task_id) as taskExecNum,
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS taskFinishNum
FROM task_info t
left join enterprise_inspections ei on t.id = ei.task_id
left join inspections_log il on ei.id = il.inspections_id
left join enterprises e on e.id = ei.enterprise_id
left join task_tag tt on t.id = tt.task_id
left join tag_library tl on tl.id = tt.tag_id
WHERE
t.deleted = 0 and ei.deleted = 0 and il.deleted = 0 GROUP BY t.id
<if test="userId != null and userId != ''">
AND t.user_id = #{userId}
t.deleted = 0 and ei.deleted = 0 and t.status = 2
<if test="params.userId != null and params.userId != ''">
AND ei.user_id = #{params.userId}
</if>
<if test="deptId != null and deptId != ''">
AND e.department_id = #{deptId}
<if test="params.priority != null and params.priority != ''">
AND t.priority = #{params.priority}
</if>
# ORDER BY t.create_time DESC
# LIMIT #{offset}, #{rows}
<if test="params.status != null and params.status != ''">
AND t.priority = #{params.status}
</if>
<if test="params.deptId != null and params.deptId != ''">
AND e.department_id = #{params.deptId}
</if>
<if test="params.endTime != null and params.endTime != ''">
AND t.end_date between #{params.startTime} and #{params.endTime}
</if>
<if test="params.tagList != null and params. tagList != ''">
AND tl.id in
<foreach collection="params.tagList" item="tagId" open="(" separator="," close=")">
#{tagId}
</foreach>
</if>
GROUP BY t.id
</select>
<select id="selectPageByEnterpriseId" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO">
SELECT
t.*
FROM task_info t
left join enterprise_inspections ei on t.id = ei.task_id
WHERE
t.deleted = 0 and ei.deleted = 0 and ei.enterprise_id = #{reqVO.enterpriseId}
GROUP BY t.id
ORDER BY t.create_time DESC
SELECT
t.*
FROM task_info t
left join enterprise_inspections ei on t.id = ei.task_id
WHERE
t.deleted = 0 and ei.deleted = 0 and ei.enterprise_id = #{reqVO.enterpriseId}
GROUP BY t.id
ORDER BY t.create_time DESC
</select>
</mapper>

Loading…
Cancel
Save